@@ -100,8 +100,9 @@ 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 =
104
-
103
+ // import reporting.trace
104
+ final def subsumes (y : CaptureRef )(using Context ): Boolean = // trace.force(i"subsumes $this, $y"):
105
+
105
106
def subsumingRefs (x : Type , y : Type ): Boolean = x match
106
107
case x : CaptureRef => y match
107
108
case y : CaptureRef => x.subsumes(y)
@@ -137,20 +138,26 @@ trait CaptureRef extends TypeProxy, ValueType:
137
138
case MaybeCapability (y1) => this .stripMaybe.subsumes(y1)
138
139
case y : TypeRef if y.symbol.info.derivesFrom(defn.Caps_CapSet ) =>
139
140
y.info match
140
- case _ : TypeAlias => y.captureSetOfInfo.elems.exists (this .subsumes)
141
+ case _ : TypeAlias => y.captureSetOfInfo.elems.forall (this .subsumes)
141
142
case TypeBounds (_, hi : CaptureRef ) => this .subsumes(hi)
142
- case _ => false
143
+ case _ => y.captureSetOfInfo.elems.forall( this .subsumes)
143
144
case _ => false
144
145
|| this .match
145
146
case ReachCapability (x1) => x1.subsumes(y.stripReach)
146
147
case x : TermRef => viaInfo(x.info)(subsumingRefs(_, y))
147
148
case x : TermParamRef => subsumesExistentially(x, y)
148
- case x : TypeRef if x.symbol.info. derivesFrom(defn.Caps_CapSet ) =>
149
+ case x : TypeRef if x.derivesFrom(defn.Caps_CapSet ) =>
149
150
x.info match
150
- case _ : TypeAlias => x.captureSetOfInfo.elems.exists(_.subsumes(y))
151
- case TypeBounds (lo : CaptureRef , _) => lo.subsumes(y)
152
- case _ => false
151
+ case _ : TypeAlias =>
152
+ x.captureSetOfInfo.elems.exists(_.subsumes(y))
153
+ case TypeBounds (lo : CaptureRef , _) =>
154
+ lo.subsumes(y)
155
+ case _ =>
156
+ x.captureSetOfInfo.elems.exists(_.subsumes(y))
153
157
case x : TypeRef => assumedContainsOf(x).contains(y)
158
+ case AnnotatedType (parent, ann)
159
+ if ann.symbol.isRetains && parent.derivesFrom(defn.Caps_CapSet ) =>
160
+ ann.tree.toCaptureSet.elems.exists(_.subsumes(y))
154
161
case _ => false
155
162
end subsumes
156
163
0 commit comments