@@ -95,6 +95,7 @@ class CheckCaptures extends Recheck:
95
95
val ref = sym.termRef
96
96
def recur (env : Env ): Unit =
97
97
if env.isOpen && env.owner != sym.enclosure then
98
+ capt.println(i " Mark $sym free in ${env.owner}" )
98
99
checkElem(ref, env.captured, pos)
99
100
recur(env.outer)
100
101
if ref.isTracked then recur(curEnv)
@@ -153,7 +154,7 @@ class CheckCaptures extends Recheck:
153
154
154
155
override def recheck (tree : Tree , pt : Type = WildcardType )(using Context ): Type =
155
156
val saved = curEnv
156
- if pt.needsBox && ! curEnv.isBoxed then
157
+ if pt.needsBox && ! curEnv.isBoxed && false then // ^^^ refine
157
158
curEnv = Env (NoSymbol , CaptureSet .Var (), true , curEnv)
158
159
try
159
160
val res = super .recheck(tree, pt)
@@ -171,15 +172,14 @@ class CheckCaptures extends Recheck:
171
172
172
173
def checkNotGlobal (tree : Tree , allArgs : Tree * )(using Context ): Unit =
173
174
if disallowGlobal then
174
- // println(i"checking $arg in $tree: ${arg.tpe.captureSet}")
175
175
tree match
176
176
case LambdaTypeTree (_, restpt) =>
177
177
checkNotGlobal(restpt, allArgs* )
178
178
case _ =>
179
179
for ref <- tree.tpe.captureSet.elems do
180
180
val isGlobal = ref match
181
- case ref : TypeRef => ref.isRootCapability
182
- case ref : TermRef => ref.prefix != NoPrefix && ref.symbol.hasAnnotation(defn.AbilityAnnot )
181
+ case ref : TermRef =>
182
+ ref.isRootCapability || ref.prefix != NoPrefix && ref.symbol.hasAnnotation(defn.AbilityAnnot )
183
183
case _ => false
184
184
val what = if ref.isRootCapability then " universal" else " global"
185
185
if isGlobal then
@@ -196,7 +196,9 @@ class CheckCaptures extends Recheck:
196
196
def traverse (tree : Tree )(using Context ) =
197
197
tree match
198
198
case tree1 @ TypeApply (fn, args) if disallowGlobal =>
199
- for arg <- args do checkNotGlobal(arg, args* )
199
+ for arg <- args do
200
+ // println(i"checking $arg in $tree: ${arg.tpe.captureSet}")
201
+ checkNotGlobal(arg, args* )
200
202
case _ =>
201
203
traverseChildren(tree)
202
204
0 commit comments