Skip to content

Commit bd4f772

Browse files
committed
Don't stop at environments with empty capture sets in markFree
Needed so that markFree can get to where it needs to check reach capabilities of classes.
1 parent eaa56a3 commit bd4f772

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ object CheckCaptures:
5959

6060
def isOutermost = outer0 == null
6161

62-
/** If an environment is open it tracks free references */
63-
def isOpen(using Context) = !captured.isAlwaysEmpty && kind != EnvKind.Boxed
64-
6562
def outersIterator: Iterator[Env] = new:
6663
private var cur = Env.this
6764
def hasNext = !cur.isOutermost
@@ -528,7 +525,7 @@ class CheckCaptures extends Recheck, SymTransformer:
528525
case _ =>
529526

530527
def recur(cs: CaptureSet, env: Env, lastEnv: Env | Null): Unit =
531-
if env.isOpen && !env.owner.isStaticOwner && !cs.isAlwaysEmpty then
528+
if env.kind != EnvKind.Boxed && !env.owner.isStaticOwner && !cs.isAlwaysEmpty then
532529
// Only captured references that are visible from the environment
533530
// should be included.
534531
val included = cs.filter: c =>
@@ -556,7 +553,7 @@ class CheckCaptures extends Recheck, SymTransformer:
556553
def isRetained(ref: Capability): Boolean = ref.pathRoot match
557554
case root: ThisType => ctx.owner.isContainedIn(root.cls)
558555
case _ => true
559-
if sym.exists && curEnv.isOpen then
556+
if sym.exists && curEnv.kind != EnvKind.Boxed then
560557
markFree(capturedVars(sym).filter(isRetained), tree)
561558

562559
/** If `tp` (possibly after widening singletons) is an ExprType

0 commit comments

Comments
 (0)