Skip to content

Commit c4482f1

Browse files
committed
Try to remove CaptureParam flag
1 parent 384eab4 commit c4482f1

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,6 @@ object Flags {
380380
/** Tracked modifier for class parameter / a class with some tracked parameters */
381381
val (Tracked @ _, _, Dependent @ _) = newFlags(46, "tracked")
382382

383-
val (CaptureParam @ _, _, _) = newFlags(47, "capture-param")
384-
385383
// ------------ Flags following this one are not pickled ----------------------------------
386384

387385
/** Symbol is not a member of its owner */
@@ -438,6 +436,8 @@ object Flags {
438436
/** Symbol is a constructor proxy (either companion, or apply method) */
439437
val (ConstructorProxy @ _, _, _) = newFlags(62, "<constructor proxy>") // (could be merged with Lifted)
440438

439+
val CaptureParam = ConstructorProxy
440+
441441
// --------- Combined Flag Sets and Conjunctions ----------------------
442442

443443
/** All possible flags */
@@ -471,7 +471,7 @@ object Flags {
471471
val FromStartFlags: FlagSet = commonFlags(
472472
Module, Package, Deferred, Method, Case, Enum, Param, ParamAccessorOrInto,
473473
Scala2SpecialFlags, MutableOrOpen, Opaque, Touched, JavaStatic,
474-
OuterOrCovariant, LabelOrContravariant, CaseAccessor, Tracked, CaptureParam,
474+
OuterOrCovariant, LabelOrContravariant, CaseAccessor, Tracked,
475475
Extension, NonMember, Implicit, Given, Permanent, Synthetic, Exported,
476476
SuperParamAliasOrScala2x, Inline, Macro, ConstructorProxy, Invisible)
477477

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,7 @@ object Types extends TypeUtils {
770770
case tp: ClassInfo => tp.appliedRef
771771
case _ => widenIfUnstable
772772
}
773-
// The dummy term capture variable can only be found in a capture set.
774-
val excluded1 = if ctx.mode.is(Mode.InCaptureSet) then excluded else excluded | CaptureParam
775-
findMember(name, pre, required, excluded1)
773+
findMember(name, pre, required, excluded)
776774
}
777775

778776
/** The implicit members with given name. If there are none and the denotation

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ trait TypeAssigner {
162162
// if this fails.
163163
ctx.javaFindMember(name, pre, lookInCompanion = false)
164164
else
165-
// The dummy term capture variable can only be found in a capture set.
166-
val excluded = if ctx.mode.is(Mode.InCaptureSet) then EmptyFlags else CaptureParam
167-
qualType.findMember(name, pre, excluded = excluded)
165+
qualType.findMember(name, pre)
168166

169167
if reallyExists(mbr) && NamedType.validPrefix(qualType) then qualType.select(name, mbr)
170168
else if qualType.isErroneous || name.toTermName == nme.ERROR then UnspecifiedErrorType

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
626626
val saved2 = foundUnderScala2
627627
unimported = Set.empty
628628
foundUnderScala2 = NoType
629-
// The dummy term capture variable can only be found in a capture set.
630-
val excluded = if ctx.mode.is(Mode.InCaptureSet) then EmptyFlags else CaptureParam
631629
try
632-
val found = findRef(name, pt, EmptyFlags, excluded, tree.srcPos)
630+
val found = findRef(name, pt, EmptyFlags, EmptyFlags, tree.srcPos)
633631
if foundUnderScala2.exists && !(foundUnderScala2 =:= found) then
634632
report.migrationWarning(
635633
em"""Name resolution will change.
@@ -651,7 +649,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
651649
*/
652650
def checkNotShadowed(ownType: Type): Type =
653651
ownType match
654-
case ownType: TermRef if ownType.symbol.is(ConstructorProxy) =>
652+
case ownType: TermRef if ownType.symbol.is(ConstructorProxy) && !ctx.mode.is(Mode.InCaptureSet) =>
655653
findRef(name, pt, EmptyFlags, ConstructorProxy, tree.srcPos) match
656654
case shadowed: TermRef if !shadowed.symbol.maybeOwner.isEmptyPackage =>
657655
pt match
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import language.experimental.captureChecking
2+
3+
def f(x: AnyRef^, C: AnyRef^) =
4+
def g[C^ <: {x}](y: AnyRef^{C}): AnyRef^{x} = y

0 commit comments

Comments
 (0)