@@ -59,9 +59,6 @@ object CheckCaptures:
59
59
60
60
def isOutermost = outer0 == null
61
61
62
- /** If an environment is open it tracks free references */
63
- def isOpen (using Context ) = ! captured.isAlwaysEmpty && kind != EnvKind .Boxed
64
-
65
62
def outersIterator : Iterator [Env ] = new :
66
63
private var cur = Env .this
67
64
def hasNext = ! cur.isOutermost
@@ -528,7 +525,7 @@ class CheckCaptures extends Recheck, SymTransformer:
528
525
case _ =>
529
526
530
527
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
532
529
// Only captured references that are visible from the environment
533
530
// should be included.
534
531
val included = cs.filter: c =>
@@ -556,7 +553,7 @@ class CheckCaptures extends Recheck, SymTransformer:
556
553
def isRetained (ref : Capability ): Boolean = ref.pathRoot match
557
554
case root : ThisType => ctx.owner.isContainedIn(root.cls)
558
555
case _ => true
559
- if sym.exists && curEnv.isOpen then
556
+ if sym.exists && curEnv.kind != EnvKind . Boxed then
560
557
markFree(capturedVars(sym).filter(isRetained), tree)
561
558
562
559
/** If `tp` (possibly after widening singletons) is an ExprType
0 commit comments