Skip to content

Commit 8da15f8

Browse files
committed
AST: Add an extension point to TypeMatcher to always mismatch generic parameters
1 parent 89418c6 commit 8da15f8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

include/swift/AST/TypeMatcher.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,21 @@ class TypeMatcher {
195195
TRIVIAL_CASE(ModuleType)
196196
TRIVIAL_CASE(DynamicSelfType)
197197
TRIVIAL_CASE(ArchetypeType)
198-
TRIVIAL_CASE(GenericTypeParamType)
199198
TRIVIAL_CASE(DependentMemberType)
200199

200+
bool visitGenericTypeParamType(CanGenericTypeParamType firstType,
201+
Type secondType,
202+
Type sugaredFirstType) {
203+
/* If the types match, continue. */
204+
if (!Matcher.asDerived().alwaysMismatchGenericParams() &&
205+
firstType->isEqual(secondType))
206+
return true;
207+
208+
/* Otherwise, let the derived class deal with the mismatch. */
209+
return mismatch(firstType.getPointer(), secondType,
210+
sugaredFirstType);
211+
}
212+
201213
/// FIXME: Split this out into cases?
202214
bool visitAnyFunctionType(CanAnyFunctionType firstFunc, Type secondType,
203215
Type sugaredFirstType) {
@@ -300,6 +312,8 @@ class TypeMatcher {
300312
#undef TRIVIAL_CASE
301313
};
302314

315+
bool alwaysMismatchGenericParams() const { return false; }
316+
303317
ImplClass &asDerived() { return static_cast<ImplClass &>(*this); }
304318

305319
const ImplClass &asDerived() const {

0 commit comments

Comments
 (0)