Skip to content

Commit eaa56a3

Browse files
committed
Create environments for classes even if their capture set is empty
Needed so that markFree can get there to check reach capabilities
1 parent 3c36c3c commit eaa56a3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,6 @@ class CheckCaptures extends Recheck, SymTransformer:
11061106
try
11071107
// Setup environment to reflect the new owner.
11081108
val envForOwner: Map[Symbol, Env] = curEnv.outersIterator
1109-
.takeWhile(e => !capturedVars(e.owner).isAlwaysEmpty) // no refs can leak beyond this point
11101109
.map(e => (e.owner, e))
11111110
.toMap
11121111
def restoreEnvFor(sym: Symbol): Env =
@@ -1142,8 +1141,7 @@ class CheckCaptures extends Recheck, SymTransformer:
11421141
checkSubset(capturedVars(parent.tpe.classSymbol), localSet, parent.srcPos,
11431142
i"\nof the references allowed to be captured by $cls")
11441143
val saved = curEnv
1145-
if localSet ne CaptureSet.empty then
1146-
curEnv = Env(cls, EnvKind.Regular, localSet, curEnv)
1144+
curEnv = Env(cls, EnvKind.Regular, localSet, curEnv)
11471145
try
11481146
val thisSet = cls.classInfo.selfType.captureSet.withDescription(i"of the self type of $cls")
11491147
checkSubset(localSet, thisSet, tree.srcPos) // (2)

0 commit comments

Comments
 (0)