@@ -141,51 +141,33 @@ class TypeMatcher {
141
141
return mismatch (firstTuple.getPointer (), secondType, sugaredFirstType);
142
142
}
143
143
144
- template <typename FirstReferenceStorageType>
145
- bool handleReferenceStorageType (
146
- CanTypeWrapper<FirstReferenceStorageType> firstStorage,
147
- Type secondType, Type sugaredFirstType) {
148
- if (auto secondStorage = secondType->getAs <FirstReferenceStorageType>()) {
149
- return this ->visit (
150
- firstStorage.getReferentType (),
151
- secondStorage->getReferentType (),
152
- sugaredFirstType->getAs <FirstReferenceStorageType>()
153
- ->getReferentType ());
144
+ bool visitReferenceStorageType (CanReferenceStorageType firstStorage,
145
+ Type secondType, Type sugaredFirstType) {
146
+ auto _secondStorage = secondType->getCanonicalType ();
147
+ if (firstStorage->getKind () == _secondStorage->getKind ()) {
148
+ auto secondStorage = cast<ReferenceStorageType>(_secondStorage);
149
+ return this ->visit (firstStorage.getReferentType (),
150
+ secondStorage->getReferentType (),
151
+ sugaredFirstType->castTo <ReferenceStorageType>()
152
+ ->getReferentType ());
154
153
}
155
154
156
155
return mismatch (firstStorage.getPointer (), secondType, sugaredFirstType);
157
156
}
158
157
159
- bool visitUnownedStorageType (CanUnownedStorageType firstStorage,
160
- Type secondType, Type sugaredFirstType) {
161
- return handleReferenceStorageType (firstStorage, secondType,
162
- sugaredFirstType);
163
- }
164
-
165
- bool visitUnmanagedStorageType (CanUnmanagedStorageType firstStorage,
166
- Type secondType, Type sugaredFirstType) {
167
- return handleReferenceStorageType (firstStorage, secondType,
168
- sugaredFirstType);
169
- }
170
-
171
- bool visitWeakStorageType (CanWeakStorageType firstStorage,
172
- Type secondType, Type sugaredFirstType) {
173
- return handleReferenceStorageType (firstStorage, secondType,
174
- sugaredFirstType);
175
- }
176
-
177
- template <typename FirstNominalType>
178
- bool handleNominalType (CanTypeWrapper<FirstNominalType> firstNominal,
179
- Type secondType, Type sugaredFirstType) {
180
- if (auto secondNominal = secondType->getAs <FirstNominalType>()) {
158
+ bool visitNominalType (CanNominalType firstNominal,
159
+ Type secondType, Type sugaredFirstType) {
160
+ auto _secondNominal = secondType->getCanonicalType ();
161
+ if (firstNominal->getKind () == _secondNominal->getKind ()) {
162
+ auto secondNominal = cast<NominalType>(_secondNominal);
181
163
if (firstNominal->getDecl () != secondNominal->getDecl ())
182
164
return mismatch (firstNominal.getPointer (), secondNominal,
183
165
sugaredFirstType);
184
166
185
167
if (firstNominal.getParent ())
186
168
return this ->visit (firstNominal.getParent (),
187
169
secondNominal->getParent (),
188
- sugaredFirstType->castTo <FirstNominalType >()
170
+ sugaredFirstType->castTo <NominalType >()
189
171
->getParent ());
190
172
191
173
return true ;
@@ -194,52 +176,20 @@ class TypeMatcher {
194
176
return mismatch (firstNominal.getPointer (), secondType, sugaredFirstType);
195
177
}
196
178
197
- bool visitEnumType (CanEnumType firstEnum, Type secondType,
198
- Type sugaredFirstType) {
199
- return handleNominalType (firstEnum, secondType, sugaredFirstType);
200
- }
201
-
202
- bool visitStructType (CanStructType firstStruct, Type secondType,
203
- Type sugaredFirstType) {
204
- return handleNominalType (firstStruct, secondType, sugaredFirstType);
205
- }
206
-
207
- bool visitClassType (CanClassType firstClass, Type secondType,
208
- Type sugaredFirstType) {
209
- return handleNominalType (firstClass, secondType, sugaredFirstType);
210
- }
211
-
212
- bool visitProtocolType (CanProtocolType firstProtocol, Type secondType,
213
- Type sugaredFirstType) {
214
- return handleNominalType (firstProtocol, secondType, sugaredFirstType);
215
- }
216
-
217
- template <typename FirstMetatypeType>
218
- bool handleAnyMetatypeType (CanTypeWrapper<FirstMetatypeType> firstMeta,
219
- Type secondType, Type sugaredFirstType) {
220
- if (auto secondMeta = secondType->getAs <FirstMetatypeType>()) {
221
- if (firstMeta->getKind () != secondMeta->getKind ())
222
- return mismatch (firstMeta.getPointer (), secondMeta, sugaredFirstType);
223
-
179
+ bool visitAnyMetatypeType (CanAnyMetatypeType firstMeta,
180
+ Type secondType, Type sugaredFirstType) {
181
+ auto _secondMeta = secondType->getCanonicalType ();
182
+ if (firstMeta->getKind () == _secondMeta->getKind ()) {
183
+ auto secondMeta = cast<AnyMetatypeType>(_secondMeta);
224
184
return this ->visit (firstMeta.getInstanceType (),
225
185
secondMeta->getInstanceType (),
226
- sugaredFirstType->castTo <FirstMetatypeType >()
186
+ sugaredFirstType->castTo <AnyMetatypeType >()
227
187
->getInstanceType ());
228
188
}
229
189
230
190
return mismatch (firstMeta.getPointer (), secondType, sugaredFirstType);
231
191
}
232
192
233
- bool visitMetatypeType (CanMetatypeType firstMeta, Type secondType,
234
- Type sugaredFirstType) {
235
- return handleAnyMetatypeType (firstMeta, secondType, sugaredFirstType);
236
- }
237
-
238
- bool visitExistentialMetatypeType (CanExistentialMetatypeType firstMeta,
239
- Type secondType, Type sugaredFirstType) {
240
- return handleAnyMetatypeType (firstMeta, secondType, sugaredFirstType);
241
- }
242
-
243
193
TRIVIAL_CASE (ModuleType)
244
194
TRIVIAL_CASE (DynamicSelfType)
245
195
TRIVIAL_CASE (ArchetypeType)
@@ -332,15 +282,15 @@ class TypeMatcher {
332
282
return mismatch (firstUBGT.getPointer (), secondType, sugaredFirstType);
333
283
}
334
284
335
- template <typename FirstBoundGenericType>
336
- bool handleBoundGenericType (CanTypeWrapper<FirstBoundGenericType> firstBGT,
337
- Type secondType, Type sugaredFirstType) {
338
- if (auto secondBGT = secondType->getAs <FirstBoundGenericType>()) {
285
+ bool visitBoundGenericType (CanBoundGenericType firstBGT,
286
+ Type secondType, Type sugaredFirstType) {
287
+ auto _secondBGT = secondType->getCanonicalType ();
288
+ if (firstBGT->getKind () == _secondBGT->getKind ()) {
289
+ auto secondBGT = cast<BoundGenericType>(_secondBGT);
339
290
if (firstBGT->getDecl () != secondBGT->getDecl ())
340
291
return mismatch (firstBGT.getPointer (), secondBGT, sugaredFirstType);
341
292
342
- auto sugaredFirstBGT
343
- = sugaredFirstType->castTo <FirstBoundGenericType>();
293
+ auto sugaredFirstBGT = sugaredFirstType->castTo <BoundGenericType>();
344
294
if (firstBGT->getParent () &&
345
295
!this ->visit (firstBGT.getParent (), secondBGT->getParent (),
346
296
sugaredFirstBGT->getParent ()))
@@ -360,21 +310,6 @@ class TypeMatcher {
360
310
return mismatch (firstBGT.getPointer (), secondType, sugaredFirstType);
361
311
}
362
312
363
- bool visitBoundGenericClassType (CanBoundGenericClassType firstBGT,
364
- Type secondType, Type sugaredFirstType) {
365
- return handleBoundGenericType (firstBGT, secondType, sugaredFirstType);
366
- }
367
-
368
- bool visitBoundGenericEnumType (CanBoundGenericEnumType firstBGT,
369
- Type secondType, Type sugaredFirstType) {
370
- return handleBoundGenericType (firstBGT, secondType, sugaredFirstType);
371
- }
372
-
373
- bool visitBoundGenericStructType (CanBoundGenericStructType firstBGT,
374
- Type secondType, Type sugaredFirstType) {
375
- return handleBoundGenericType (firstBGT, secondType, sugaredFirstType);
376
- }
377
-
378
313
TRIVIAL_CASE (TypeVariableType)
379
314
380
315
#undef TRIVIAL_CASE
0 commit comments