@@ -100,7 +100,8 @@ trait CaptureRef extends TypeProxy, ValueType:
100
100
* x: x1.type /\ x1 subsumes y ==> x subsumes y
101
101
* TODO: Document path cases
102
102
*/
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"):
104
105
105
106
def subsumingRefs (x : Type , y : Type ): Boolean = x match
106
107
case x : CaptureRef => y match
@@ -135,14 +136,28 @@ trait CaptureRef extends TypeProxy, ValueType:
135
136
case _ => false
136
137
|| viaInfo(y.info)(subsumingRefs(this , _))
137
138
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)
138
144
case _ => false
139
145
|| this .match
140
146
case ReachCapability (x1) => x1.subsumes(y.stripReach)
141
147
case x : TermRef => viaInfo(x.info)(subsumingRefs(_, y))
142
148
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))
146
161
case _ => false
147
162
end subsumes
148
163
0 commit comments