Skip to content

Commit 3bd5687

Browse files
committed
IDE: Better archetype etiquette in ConformingMethodListCallbacks::getMatchingMethods()
1 parent fe8f6ae commit 3bd5687

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/IDE/ConformingMethodList.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,19 @@ void ConformingMethodListCallbacks::getMatchingMethods(
174174
if (FD->isStatic() || FD->isOperator())
175175
return false;
176176

177-
auto resultTy = T->getTypeOfMember(CurModule, FD,
178-
FD->getResultInterfaceType());
177+
assert(!T->hasTypeParameter());
178+
179+
// T may contain primary archetypes from some fixed generic signature G.
180+
// This might be unrelated to the generic signature of FD. However if
181+
// FD has a generic parameter of its own and it returns a type containing
182+
// that parameter, we want to map it to the corresponding archetype
183+
// from the generic environment of FD, because all we do with the
184+
// resulting type is check conformance. If the conformance is conditional,
185+
// we might run into trouble with really complicated cases but the fake
186+
// archetype setup will mostly work.
187+
auto substitutions = T->getMemberSubstitutionMap(
188+
CurModule, FD, FD->getGenericEnvironment());
189+
auto resultTy = FD->getResultInterfaceType().subst(substitutions);
179190
if (resultTy->is<ErrorType>())
180191
return false;
181192

0 commit comments

Comments
 (0)