Skip to content

Commit a4e1546

Browse files
committed
Check use sets of non-static inner classes
These fell through the cracks before since we only considered named outer refs. But inner classes can have outer this references check needd to be tracked in use sets.
1 parent de1c3b7 commit a4e1546

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,12 @@ class CheckCaptures extends Recheck, SymTransformer:
407407
else i"references $cs1$cs1description are not all",
408408
cs1, cs2, pos, provenance)
409409

410-
/** If `sym` is a class or method nested inside a term, a capture set variable representing
411-
* the captured variables of the environment associated with `sym`.
410+
/** If `sym` is a method or a non-static inner class, a capture set variable
411+
* representing the captured variables of the environment associated with `sym`.
412412
*/
413413
def capturedVars(sym: Symbol)(using Context): CaptureSet =
414414
myCapturedVars.getOrElseUpdate(sym,
415-
if sym.ownersIterator.exists(_.isTerm)
415+
if sym.isTerm || !sym.owner.isStaticOwner
416416
then CaptureSet.Var(sym.owner, level = ccState.symLevel(sym))
417417
else CaptureSet.empty)
418418

0 commit comments

Comments
 (0)