@@ -555,7 +555,7 @@ class CheckCaptures extends Recheck, SymTransformer:
555
555
// println(i"Include call or box capture $included from $cs in ${env.owner}/${env.captured}/${env.captured.owner}/${env.kind}")
556
556
checkSubset(included, env.captured, tree.srcPos, provenance(env))
557
557
capt.println(i " Include call or box capture $included from $cs in ${env.owner} --> ${env.captured}" )
558
- if ! isOfNestedMethod(env) && ! ccConfig.caplessLike then
558
+ if ! isOfNestedMethod(env) && ( ! ccConfig.caplessLike || env.kind == EnvKind . NestedInOwner ) then
559
559
val nextEnv = nextEnvToCharge(env)
560
560
if nextEnv != null && ! nextEnv.owner.isStaticOwner then
561
561
recur(included, nextEnv, env)
@@ -2107,6 +2107,12 @@ class CheckCaptures extends Recheck, SymTransformer:
2107
2107
if ! boxedOwner(env).isContainedIn(croot.symbol.owner) then
2108
2108
checkUseDeclared(c, tree.srcPos)
2109
2109
2110
+ def checkUse (c : Capability , croot : NamedType ) =
2111
+ if ccConfig.caplessLike then
2112
+ if ! env.owner.isProperlyContainedIn(croot.symbol.owner) then
2113
+ checkUseDeclared(c, tree.srcPos)
2114
+ else checkUseUnlessBoxed(c, croot)
2115
+
2110
2116
def check (cs : CaptureSet ): Unit = cs.elems.foreach(checkElem)
2111
2117
2112
2118
def checkElem (c : Capability ): Unit =
@@ -2115,7 +2121,7 @@ class CheckCaptures extends Recheck, SymTransformer:
2115
2121
c match
2116
2122
case Reach (c1) =>
2117
2123
c1.paramPathRoot match
2118
- case croot : NamedType => checkUseUnlessBoxed (c, croot)
2124
+ case croot : NamedType => checkUse (c, croot)
2119
2125
case _ => check(CaptureSet .ofTypeDeeply(c1.widen))
2120
2126
case c : TypeRef =>
2121
2127
c.paramPathRoot match
0 commit comments