@@ -93,100 +93,42 @@ trait CaptureRef extends TypeProxy, ValueType:
93
93
final def invalidateCaches () =
94
94
myCaptureSetRunId = NoRunId
95
95
96
+ /** x subsumes x
97
+ * this subsumes this.f
98
+ * x subsumes y ==> x* subsumes y, x subsumes y?
99
+ * x subsumes y ==> x* subsumes y*, x? subsumes y?
100
+ * x: x1.type /\ x1 subsumes y ==> x subsumes y
101
+ * TODO: Document path cases
102
+ */
96
103
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
104
(this eq y)
105
105
|| this .isRootCapability
106
106
|| y.match
107
107
case y : TermRef =>
108
108
y.prefix.match
109
109
case ypre : CaptureRef =>
110
- this .subsumesOld (ypre)
110
+ this .subsumes (ypre)
111
111
|| this .match
112
112
case x @ TermRef (xpre : CaptureRef , _) =>
113
113
x.symbol == y.symbol && xpre =:= ypre
114
114
case _ =>
115
115
false
116
116
case _ => false
117
117
|| y.info.match
118
- case y1 : SingletonCaptureRef => this .subsumesOld (y1)
118
+ case y1 : SingletonCaptureRef => this .subsumes (y1)
119
119
case _ => false
120
- case MaybeCapability (y1) => this .stripMaybe.subsumesOld (y1)
120
+ case MaybeCapability (y1) => this .stripMaybe.subsumes (y1)
121
121
case _ => false
122
122
|| this .match
123
- case ReachCapability (x1) => x1.subsumesOld (y.stripReach)
123
+ case ReachCapability (x1) => x1.subsumes (y.stripReach)
124
124
case x : TermRef =>
125
125
x.info match
126
- case x1 : SingletonCaptureRef => x1.subsumesOld (y)
126
+ case x1 : SingletonCaptureRef => x1.subsumes (y)
127
127
case _ => false
128
128
case x : TermParamRef => subsumesExistentially(x, y)
129
129
case x : TypeRef => assumedContainsOf(x).contains(y)
130
130
case _ => false
131
131
132
- /** x subsumes x
133
- * this subsumes this.f
134
- * x subsumes y ==> x* subsumes y, x subsumes y?
135
- * x subsumes y ==> x* subsumes y*, x? subsumes y?
136
- * x: x1.type /\ x1 subsumes y ==> x subsumes y
137
- */
138
- final def subsumesNew (y : CaptureRef )(using Context ): Boolean =
139
- def compareCaptureRefs (x : Type , y : Type ): Boolean =
140
- (x eq y)
141
- || y.match
142
- case y : CaptureRef => x.match
143
- case x : CaptureRef => x.subsumesNew(y)
144
- case _ => false
145
- case _ => false
146
-
147
- def compareUndelying (x : Type ): Boolean = x match
148
- case x : SingletonCaptureRef => x.subsumesNew(y)
149
- case x : AndType => compareUndelying(x.tp1) || compareUndelying(x.tp2)
150
- case x : OrType => compareUndelying(x.tp1) && compareUndelying(x.tp2)
151
- case _ => false
152
-
153
- if (this eq y) || this .isRootCapability then return true
154
-
155
- // similar to compareNamed in TypeComparer
156
- y match
157
- case y : TermRef =>
158
- this match
159
- case x : TermRef =>
160
- val xSym = x.symbol
161
- val ySym = y.symbol
162
-
163
- // check x.f and y.f
164
- if (xSym ne NoSymbol )
165
- && (xSym eq ySym)
166
- && compareCaptureRefs(x.prefix, y.prefix)
167
- || (x.name eq y.name)
168
- && x.isPrefixDependentMemberRef
169
- && compareCaptureRefs(x.prefix, y.prefix)
170
- && x.signature == y.signature
171
- && ! (xSym.isClass && ySym.isClass)
172
- then return true
173
- case _ =>
174
-
175
- // shorten
176
- if compareCaptureRefs(this , y.prefix) then return true
177
- // underlying
178
- if compareCaptureRefs(this , y.info) then return true
179
- case MaybeCapability (y1) => return this .stripMaybe.subsumesNew(y1)
180
- case _ =>
181
-
182
- return this .match
183
- case ReachCapability (x1) => x1.subsumesNew(y.stripReach)
184
- case x : TermRef => compareUndelying(x.info)
185
- case CapturingType (x1, _) => compareUndelying(x1)
186
- case x : TermParamRef => subsumesExistentially(x, y)
187
- case x : TypeRef => assumedContainsOf(x).contains(y)
188
- case _ => false
189
-
190
132
def assumedContainsOf (x : TypeRef )(using Context ): SimpleIdentitySet [CaptureRef ] =
191
133
CaptureSet .assumedContains.getOrElse(x, SimpleIdentitySet .empty)
192
134
0 commit comments