Skip to content

Commit

Permalink
update documentation of recheck about top-level boxes
Browse files Browse the repository at this point in the history
Linyxus committed Oct 16, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4805007 commit 8bab429
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala
Original file line number Diff line number Diff line change
@@ -520,15 +520,15 @@ class CheckCaptures extends Recheck, SymTransformer:
case _: RefTree => true
case _ => false

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

0 comments on commit 8bab429

Please sign in to comment.