@@ -93,23 +93,59 @@ trait CaptureRef extends TypeProxy, ValueType:
93
93
final def invalidateCaches () =
94
94
myCaptureSetRunId = NoRunId
95
95
96
+ final def subsumes (y : CaptureRef )(using Context ): Boolean =
97
+ val was = subsumesOld(y)
98
+ val now = subsumesNew(y)
99
+ if was != now then
100
+ println(i " diff for $this subsumes $y, now: $now, ${this .getClass}, ${y.getClass}" )
101
+ was
102
+
103
+ final def subsumesOld (y : CaptureRef )(using Context ): Boolean =
104
+ (this eq y)
105
+ || this .isRootCapability
106
+ || y.match
107
+ case y : TermRef =>
108
+ y.prefix.match
109
+ case ypre : CaptureRef =>
110
+ this .subsumesOld(ypre)
111
+ || this .match
112
+ case x @ TermRef (xpre : CaptureRef , _) =>
113
+ x.symbol == y.symbol && xpre =:= ypre
114
+ case _ =>
115
+ false
116
+ case _ => false
117
+ || y.info.match
118
+ case y1 : SingletonCaptureRef => this .subsumesOld(y1)
119
+ case _ => false
120
+ case MaybeCapability (y1) => this .stripMaybe.subsumesOld(y1)
121
+ case _ => false
122
+ || this .match
123
+ case ReachCapability (x1) => x1.subsumesOld(y.stripReach)
124
+ case x : TermRef =>
125
+ x.info match
126
+ case x1 : SingletonCaptureRef => x1.subsumesOld(y)
127
+ case _ => false
128
+ case x : TermParamRef => subsumesExistentially(x, y)
129
+ case x : TypeRef => assumedContainsOf(x).contains(y)
130
+ case _ => false
131
+
96
132
/** x subsumes x
97
133
* this subsumes this.f
98
134
* x subsumes y ==> x* subsumes y, x subsumes y?
99
135
* x subsumes y ==> x* subsumes y*, x? subsumes y?
100
136
* x: x1.type /\ x1 subsumes y ==> x subsumes y
101
137
*/
102
- final def subsumes (y : CaptureRef )(using Context ): Boolean =
138
+ final def subsumesNew (y : CaptureRef )(using Context ): Boolean =
103
139
def compareCaptureRefs (x : Type , y : Type ): Boolean =
104
140
(x eq y)
105
141
|| y.match
106
142
case y : CaptureRef => x.match
107
- case x : CaptureRef => x.subsumes (y)
143
+ case x : CaptureRef => x.subsumesNew (y)
108
144
case _ => false
109
145
case _ => false
110
146
111
147
def compareUndelying (x : Type ): Boolean = x match
112
- case x : SingletonCaptureRef => x.subsumes (y)
148
+ case x : SingletonCaptureRef => x.subsumesNew (y)
113
149
case x : AndType => compareUndelying(x.tp1) || compareUndelying(x.tp2)
114
150
case x : OrType => compareUndelying(x.tp1) && compareUndelying(x.tp2)
115
151
case _ => false
@@ -140,11 +176,11 @@ trait CaptureRef extends TypeProxy, ValueType:
140
176
if compareCaptureRefs(this , y.prefix) then return true
141
177
// underlying
142
178
if compareCaptureRefs(this , y.info) then return true
143
- case MaybeCapability (y1) => return this .stripMaybe.subsumes (y1)
179
+ case MaybeCapability (y1) => return this .stripMaybe.subsumesNew (y1)
144
180
case _ =>
145
181
146
182
return this .match
147
- case ReachCapability (x1) => x1.subsumes (y.stripReach)
183
+ case ReachCapability (x1) => x1.subsumesNew (y.stripReach)
148
184
case x : TermRef => compareUndelying(x.info)
149
185
case CapturingType (x1, _) => compareUndelying(x1)
150
186
case x : TermParamRef => subsumesExistentially(x, y)
0 commit comments