@@ -100,7 +100,8 @@ trait CaptureRef extends TypeProxy, ValueType:
100100 * x: x1.type /\ x1 subsumes y ==> x subsumes y
101101 * TODO: Document path cases
102102 */
103- final def subsumes (y : CaptureRef )(using Context ): Boolean =
103+ // import reporting.trace
104+ final def subsumes (y : CaptureRef )(using Context ): Boolean = // trace.force(i"subsumes $this, $y"):
104105
105106 def subsumingRefs (x : Type , y : Type ): Boolean = x match
106107 case x : CaptureRef => y match
@@ -135,14 +136,28 @@ trait CaptureRef extends TypeProxy, ValueType:
135136 case _ => false
136137 || viaInfo(y.info)(subsumingRefs(this , _))
137138 case MaybeCapability (y1) => this .stripMaybe.subsumes(y1)
139+ case y : TypeRef if y.symbol.info.derivesFrom(defn.Caps_CapSet ) =>
140+ y.info match
141+ case _ : TypeAlias => y.captureSetOfInfo.elems.forall(this .subsumes)
142+ case TypeBounds (_, hi : CaptureRef ) => this .subsumes(hi)
143+ case _ => y.captureSetOfInfo.elems.forall(this .subsumes)
138144 case _ => false
139145 || this .match
140146 case ReachCapability (x1) => x1.subsumes(y.stripReach)
141147 case x : TermRef => viaInfo(x.info)(subsumingRefs(_, y))
142148 case x : TermParamRef => subsumesExistentially(x, y)
143- case x : TypeRef if x.symbol.info.derivesFrom(defn.Caps_CapSet ) =>
144- x.captureSetOfInfo.elems.exists(_.subsumes(y))
145- case x : TypeRef => assumedContainsOf(x).contains(y)
149+ case x : TypeRef if assumedContainsOf(x).contains(y) => true
150+ case x : TypeRef if x.derivesFrom(defn.Caps_CapSet ) =>
151+ x.info match
152+ case _ : TypeAlias =>
153+ x.captureSetOfInfo.elems.exists(_.subsumes(y))
154+ case TypeBounds (lo : CaptureRef , _) =>
155+ lo.subsumes(y)
156+ case _ =>
157+ x.captureSetOfInfo.elems.exists(_.subsumes(y))
158+ case AnnotatedType (parent, ann)
159+ if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
160+ ann.tree.toCaptureSet.elems.exists(_.subsumes(y))
146161 case _ => false
147162 end subsumes
148163
0 commit comments