@@ -139,9 +139,10 @@ trait CaptureRef extends TypeProxy, ValueType:
139
139
hidden.owner
140
140
case ref : NamedType =>
141
141
if ref.isCap then NoSymbol
142
- else ref.prefix match
143
- case prefix : CaptureRef => prefix.ccOwner
144
- case _ => ref.symbol
142
+ else ref.pathRoot match
143
+ case ref : ThisType => ref.cls
144
+ case ref : NamedType => ref.symbol
145
+ case _ => NoSymbol
145
146
case ref : ThisType =>
146
147
ref.cls
147
148
case QualifiedCapability (ref1) =>
@@ -222,7 +223,7 @@ trait CaptureRef extends TypeProxy, ValueType:
222
223
def viaInfo (info : Type )(test : Type => Boolean ): Boolean = info.dealias match
223
224
case info : SingletonCaptureRef => test(info)
224
225
case CapturingType (parent, _) =>
225
- if this .derivesFrom(defn.Caps_CapSet ) then test(info)
226
+ if this .derivesFrom(defn.Caps_CapSet ) && false then test(info)
226
227
/*
227
228
If `this` is a capture set variable `C^`, then it is possible that it can be
228
229
reached from term variables in a reachability chain through the context.
@@ -235,7 +236,7 @@ trait CaptureRef extends TypeProxy, ValueType:
235
236
case info : OrType => viaInfo(info.tp1)(test) && viaInfo(info.tp2)(test)
236
237
case _ => false
237
238
238
- (this eq y)
239
+ try (this eq y)
239
240
|| maxSubsumes(y, canAddHidden = ! vs.isOpen)
240
241
|| y.match
241
242
case y : TermRef if ! y.isCap =>
@@ -262,9 +263,13 @@ trait CaptureRef extends TypeProxy, ValueType:
262
263
// They can be other capture set variables, which are bounded by `CapSet`,
263
264
// like `def test[X^, Y^, Z >: X <: Y]`.
264
265
y.info match
265
- case TypeBounds (_, hi : CaptureRef ) => this .subsumes(hi)
266
+ case TypeBounds (_, hi @ CapturingType (parent, refs)) if parent.derivesFrom(defn.Caps_CapSet ) =>
267
+ refs.elems.forall(this .subsumes)
268
+ case TypeBounds (_, hi : CaptureRef ) =>
269
+ this .subsumes(hi)
266
270
case _ => y.captureSetOfInfo.elems.forall(this .subsumes)
267
271
case CapturingType (parent, refs) if parent.derivesFrom(defn.Caps_CapSet ) || this .derivesFrom(defn.Caps_CapSet ) =>
272
+ assert(false , this )
268
273
/* The second condition in the guard is for `this` being a `CapSet^{a,b...}` and etablishing a
269
274
potential reachability chain through `y`'s capture to a binding with
270
275
`this`'s capture set (cf. `CapturingType` case in `def viaInfo` above for more context).
@@ -277,13 +282,18 @@ trait CaptureRef extends TypeProxy, ValueType:
277
282
case x : TypeRef if assumedContainsOf(x).contains(y) => true
278
283
case x : TypeRef if x.derivesFrom(defn.Caps_CapSet ) =>
279
284
x.info match
285
+ case TypeBounds (lo @ CapturingType (parent, refs), _) if parent.derivesFrom(defn.Caps_CapSet ) =>
286
+ refs.elems.exists(_.subsumes(y))
280
287
case TypeBounds (lo : CaptureRef , _) =>
281
288
lo.subsumes(y)
282
289
case _ =>
283
290
x.captureSetOfInfo.elems.exists(_.subsumes(y))
284
291
case CapturingType (parent, refs) if parent.derivesFrom(defn.Caps_CapSet ) =>
285
- refs.elems.exists(_.subsumes(y) )
292
+ assert( false , this )
286
293
case _ => false
294
+ catch case ex : AssertionError =>
295
+ println(i " error while subsumes $this >> $y" )
296
+ throw ex
287
297
end subsumes
288
298
289
299
/** This is a maximal capability that subsumes `y` in given context and VarState.
@@ -312,7 +322,7 @@ trait CaptureRef extends TypeProxy, ValueType:
312
322
else
313
323
! y.stripReadOnly.isCap
314
324
&& ! yIsExistential
315
- && ! y.isInstanceOf [ParamRef ]
325
+ && ! y.stripReadOnly. isInstanceOf [ParamRef ]
316
326
317
327
vs.ifNotSeen(this )(hidden.elems.exists(_.subsumes(y)))
318
328
|| levelOK
@@ -325,21 +335,15 @@ trait CaptureRef extends TypeProxy, ValueType:
325
335
if ! result then
326
336
ccState.addNote(CaptureSet .ExistentialSubsumesFailure (x, y))
327
337
result
338
+ case _ if this .isCap =>
339
+ if y.isCap then true
340
+ else if yIsExistential then false
341
+ else y.derivesFromSharedCapability
342
+ || canAddHidden && vs != VarState .HardSeparate && CCState .capIsRoot
328
343
case _ =>
329
344
y match
330
345
case ReadOnlyCapability (y1) => this .stripReadOnly.maxSubsumes(y1, canAddHidden)
331
- case _ if this .isCap =>
332
- y.isCap
333
- || y.derivesFromSharedCapability
334
- || ! yIsExistential
335
- && canAddHidden
336
- && vs != VarState .HardSeparate
337
- && (CCState .capIsRoot
338
- // || { println(i"no longer $this maxSubsumes $y, ${y.isCap}"); false } // debug
339
- )
340
- || false
341
- case _ =>
342
- false
346
+ case _ => false
343
347
344
348
/** `x covers y` if we should retain `y` when computing the overlap of
345
349
* two footprints which have `x` respectively `y` as elements.
0 commit comments