Skip to content

Commit 8a201af

Browse files
committed
IDE: Fix a usage of lookupVisibleMemberDecls() to not pass in an existential type
It's better to use the 'Self' archetype here.
1 parent f81c23d commit 8a201af

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,13 +4178,12 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
41784178
}
41794179
}
41804180

4181-
void addDesignatedInitializers(Type CurrTy) {
4181+
void addDesignatedInitializers(NominalTypeDecl *NTD) {
41824182
if (hasFuncIntroducer || hasVarIntroducer || hasTypealiasIntroducer ||
41834183
hasOverridabilityModifier)
41844184
return;
41854185

4186-
assert(CurrTy);
4187-
const auto *CD = dyn_cast_or_null<ClassDecl>(CurrTy->getAnyNominal());
4186+
const auto *CD = dyn_cast<ClassDecl>(NTD);
41884187
if (!CD)
41894188
return;
41904189
if (!CD->hasSuperclass())
@@ -4201,14 +4200,12 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
42014200
}
42024201
}
42034202

4204-
void addAssociatedTypes(Type CurrTy) {
4203+
void addAssociatedTypes(NominalTypeDecl *NTD) {
42054204
if (!hasTypealiasIntroducer &&
42064205
(hasFuncIntroducer || hasVarIntroducer || hasInitializerModifier ||
42074206
hasOverride || hasOverridabilityModifier))
42084207
return;
42094208

4210-
NominalTypeDecl *NTD = CurrTy->getAnyNominal();
4211-
42124209
for (auto Conformance : NTD->getAllConformances()) {
42134210
auto Proto = Conformance->getProtocol();
42144211
if (!Proto->isAccessibleFrom(CurrDeclContext))
@@ -4234,13 +4231,14 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
42344231
if (isa<ProtocolDecl>(CurrDeclContext))
42354232
return;
42364233

4237-
Type CurrTy = CurrDeclContext->getDeclaredTypeInContext();
4234+
Type CurrTy = CurrDeclContext->getSelfTypeInContext();
4235+
auto *NTD = CurrDeclContext->getSelfNominalTypeDecl();
42384236
if (CurrTy && !CurrTy->is<ErrorType>()) {
42394237
lookupVisibleMemberDecls(*this, CurrTy, CurrDeclContext,
42404238
TypeResolver,
42414239
/*includeInstanceMembers=*/false);
4242-
addDesignatedInitializers(CurrTy);
4243-
addAssociatedTypes(CurrTy);
4240+
addDesignatedInitializers(NTD);
4241+
addAssociatedTypes(NTD);
42444242
}
42454243
}
42464244
};

0 commit comments

Comments
 (0)