Skip to content

Commit 9e20cf2

Browse files
committed
update documentation of recheck about top-level boxes
1 parent 4805007 commit 9e20cf2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,15 +520,15 @@ class CheckCaptures extends Recheck, SymTransformer:
520520
case _: RefTree => true
521521
case _ => false
522522

523-
/** If expected type `pt` is boxed, don't propagate free variables.
523+
/** If expected type `pt` is boxed and the tree is a function or a reference,
524+
* don't propagate free variables.
524525
* Otherwise, if the result type is boxed, simulate an unboxing by
525526
* adding all references in the boxed capture set to the current environment.
526527
*/
527528
override def recheck(tree: Tree, pt: Type = WildcardType)(using Context): Type =
528529
if tree.isTerm && pt.isBoxedCapturing then
529530
val saved = curEnv
530531
if tree.isRefTree || tree.isFunctionLiteral then
531-
curEnv = Env(curEnv.owner, CaptureSet.Var(), isBoxed = true, curEnv)
532532
curEnv = Env(curEnv.owner, nestedInOwner = false, CaptureSet.Var(), isBoxed = true, curEnv)
533533
try super.recheck(tree, pt)
534534
finally curEnv = saved

0 commit comments

Comments
 (0)