Skip to content

Commit d11c513

Browse files
committed
First step: make capture set propagation shallow
1 parent 28a4921 commit d11c513

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ class CheckCaptures extends Recheck, SymTransformer:
555555
//println(i"Include call or box capture $included from $cs in ${env.owner}/${env.captured}/${env.captured.owner}/${env.kind}")
556556
checkSubset(included, env.captured, tree.srcPos, provenance(env))
557557
capt.println(i"Include call or box capture $included from $cs in ${env.owner} --> ${env.captured}")
558-
if !isOfNestedMethod(env) then
558+
if !isOfNestedMethod(env) && !ccConfig.caplessLike then
559559
val nextEnv = nextEnvToCharge(env)
560560
if nextEnv != null && !nextEnv.owner.isStaticOwner then
561561
recur(included, nextEnv, env)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ object ccConfig:
2121
*/
2222
inline val deferredReaches = false
2323

24+
/** Use the capless-like scheme for capture checking:
25+
* - preciser capture sets for curried function types
26+
* - a different rule for handling application captures
27+
*/
28+
inline val caplessLike = true
29+
2430
/** Check that if a type map (which is not a BiTypeMap) maps initial capture
2531
* set variable elements to themselves it will not map any elements added in
2632
* the future to something else. That is, we can safely use a capture set

0 commit comments

Comments
 (0)