@@ -1239,10 +1239,9 @@ class CheckCaptures extends Recheck, SymTransformer:
12391239 |must conform to this type. """
12401240
12411241 tree.tpt match
1242- case tpt : InferredTypeTree if ! isExemptFromChecks =>
1243- if ! sym.isLocalToCompilationUnit
1244- // Symbols that can't be seen outside the compilation unit can have inferred types
1245- // except for the else clause below.
1242+ case tpt : InferredTypeTree =>
1243+ if ! sym.isLocalToCompilationUnit && ! isExemptFromChecks
1244+ // Symbols that can't be seen outside the compilation unit can have inferred types
12461245 then
12471246 val expected = tpt.tpe.dropAllRetains
12481247 todoAtPostCheck += { () =>
@@ -1251,18 +1250,19 @@ class CheckCaptures extends Recheck, SymTransformer:
12511250 // The check that inferred <: expected is done after recheck so that it
12521251 // does not interfere with normal rechecking by constraining capture set variables.
12531252 }
1254- else if sym.is(Private )
1255- && ! sym.isLocalToCompilationUnitIgnoringPrivate
1256- && tree.tpt.nuType.spanCaptureSet.containsTerminalCapability
1253+ if ! sym.isLocalToCompilationUnitIgnoringPrivate
12571254 && contributesFreshToClass(sym)
12581255 // Private symbols capturing a root capability need explicit types
12591256 // so that we can compute field constributions to class instance
12601257 // capture sets across compilation units.
12611258 then
1262- report.error(
1263- em """ $sym needs an explicit type because it captures a root capability in its type ${tree.tpt.nuType}.
1264- |Fields of publicily accessible classes that capture a root capability need to be given an explicit type. """ ,
1265- tpt.srcPos)
1259+ todoAtPostCheck += { () =>
1260+ if sym.info.spanCaptureSet.containsTerminalCapability then
1261+ report.error(
1262+ em """ $sym needs an explicit type because it captures a root capability in its type ${tree.tpt.nuType}.
1263+ |Fields of publicily accessible classes that capture a root capability need to be given an explicit type. """ ,
1264+ tpt.srcPos)
1265+ }
12661266 case _ =>
12671267 tp
12681268 end checkInferredResult
0 commit comments