@@ -139,9 +139,10 @@ trait CaptureRef extends TypeProxy, ValueType:
139139 hidden.owner
140140 case ref : NamedType =>
141141 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
145146 case ref : ThisType =>
146147 ref.cls
147148 case QualifiedCapability (ref1) =>
@@ -222,7 +223,7 @@ trait CaptureRef extends TypeProxy, ValueType:
222223 def viaInfo (info : Type )(test : Type => Boolean ): Boolean = info.dealias match
223224 case info : SingletonCaptureRef => test(info)
224225 case CapturingType (parent, _) =>
225- if this .derivesFrom(defn.Caps_CapSet ) then test(info)
226+ if this .derivesFrom(defn.Caps_CapSet ) && false then test(info)
226227 /*
227228 If `this` is a capture set variable `C^`, then it is possible that it can be
228229 reached from term variables in a reachability chain through the context.
@@ -235,7 +236,7 @@ trait CaptureRef extends TypeProxy, ValueType:
235236 case info : OrType => viaInfo(info.tp1)(test) && viaInfo(info.tp2)(test)
236237 case _ => false
237238
238- (this eq y)
239+ try (this eq y)
239240 || maxSubsumes(y, canAddHidden = ! vs.isOpen)
240241 || y.match
241242 case y : TermRef if ! y.isCap =>
@@ -262,9 +263,13 @@ trait CaptureRef extends TypeProxy, ValueType:
262263 // They can be other capture set variables, which are bounded by `CapSet`,
263264 // like `def test[X^, Y^, Z >: X <: Y]`.
264265 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)
266270 case _ => y.captureSetOfInfo.elems.forall(this .subsumes)
267271 case CapturingType (parent, refs) if parent.derivesFrom(defn.Caps_CapSet ) || this .derivesFrom(defn.Caps_CapSet ) =>
272+ assert(false , this )
268273 /* The second condition in the guard is for `this` being a `CapSet^{a,b...}` and etablishing a
269274 potential reachability chain through `y`'s capture to a binding with
270275 `this`'s capture set (cf. `CapturingType` case in `def viaInfo` above for more context).
@@ -277,13 +282,18 @@ trait CaptureRef extends TypeProxy, ValueType:
277282 case x : TypeRef if assumedContainsOf(x).contains(y) => true
278283 case x : TypeRef if x.derivesFrom(defn.Caps_CapSet ) =>
279284 x.info match
285+ case TypeBounds (lo @ CapturingType (parent, refs), _) if parent.derivesFrom(defn.Caps_CapSet ) =>
286+ refs.elems.exists(_.subsumes(y))
280287 case TypeBounds (lo : CaptureRef , _) =>
281288 lo.subsumes(y)
282289 case _ =>
283290 x.captureSetOfInfo.elems.exists(_.subsumes(y))
284291 case CapturingType (parent, refs) if parent.derivesFrom(defn.Caps_CapSet ) =>
285- refs.elems.exists(_.subsumes(y) )
292+ assert( false , this )
286293 case _ => false
294+ catch case ex : AssertionError =>
295+ println(i " error while subsumes $this >> $y" )
296+ throw ex
287297 end subsumes
288298
289299 /** This is a maximal capability that subsumes `y` in given context and VarState.
@@ -312,7 +322,7 @@ trait CaptureRef extends TypeProxy, ValueType:
312322 else
313323 ! y.stripReadOnly.isCap
314324 && ! yIsExistential
315- && ! y.isInstanceOf [ParamRef ]
325+ && ! y.stripReadOnly. isInstanceOf [ParamRef ]
316326
317327 vs.ifNotSeen(this )(hidden.elems.exists(_.subsumes(y)))
318328 || levelOK
@@ -325,21 +335,15 @@ trait CaptureRef extends TypeProxy, ValueType:
325335 if ! result then
326336 ccState.addNote(CaptureSet .ExistentialSubsumesFailure (x, y))
327337 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
328343 case _ =>
329344 y match
330345 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
343347
344348 /** `x covers y` if we should retain `y` when computing the overlap of
345349 * two footprints which have `x` respectively `y` as elements.
0 commit comments