Skip to content

Commit 9a5408c

Browse files
committed
IDE: Remove a usage of ArchetypeType::getRoot()
1 parent 16af433 commit 9a5408c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Diff for: lib/IDE/CompletionLookup.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,13 @@ void CompletionLookup::foundFunction(const AnyFunctionType *AFT) {
259259

260260
bool CompletionLookup::canBeUsedAsRequirementFirstType(Type selfTy,
261261
TypeAliasDecl *TAD) {
262-
auto T = TAD->getDeclaredInterfaceType();
263-
auto subMap = selfTy->getMemberSubstitutionMap(TAD);
264-
T = T.subst(subMap)->getCanonicalType();
265-
266-
ArchetypeType *archeTy = T->getAs<ArchetypeType>();
267-
if (!archeTy)
262+
if (TAD->isGeneric())
268263
return false;
269-
archeTy = archeTy->getRoot();
270264

271-
// For protocol, the 'archeTy' should match with the 'baseTy' which is the
272-
// dynamic 'Self' type of the protocol. For nominal decls, 'archTy' should
273-
// be one of the generic params in 'selfTy'. Search 'archeTy' in 'baseTy'.
274-
return selfTy.findIf([&](Type T) { return archeTy->isEqual(T); });
265+
auto T = TAD->getDeclaredInterfaceType();
266+
auto subMap = selfTy->getContextSubstitutionMap(TAD->getDeclContext());
267+
268+
return T.subst(subMap)->is<ArchetypeType>();
275269
}
276270

277271
CompletionLookup::CompletionLookup(CodeCompletionResultSink &Sink,

0 commit comments

Comments
 (0)