Skip to content

Commit 0040785

Browse files
committed
[NFC] Swap CodeCompletion's lookupQualified for TypeChecker's
This call relied on semantic member synthesis, so now it has to go through TypeChecker::lookupQualified.
1 parent dd51251 commit 0040785

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

include/swift/Sema/IDETypeChecking.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace swift {
3535
class Expr;
3636
class ExtensionDecl;
3737
class FunctionType;
38+
class LookupResult;
3839
class NominalTypeDecl;
3940
class PatternBindingDecl;
4041
class ProtocolDecl;
@@ -137,6 +138,9 @@ namespace swift {
137138
/// \returns true on success, false on error.
138139
bool typeCheckTopLevelCodeDecl(TopLevelCodeDecl *TLCD);
139140

141+
LookupResult
142+
lookupSemanticMember(DeclContext *DC, Type ty, DeclName name);
143+
140144
struct ExtensionInfo {
141145
// The extension with the declarations to apply.
142146
ExtensionDecl *Ext;

lib/IDE/CodeCompletion.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,22 +2738,21 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
27382738
return;
27392739

27402740
assert(CurrDeclContext);
2741-
SmallVector<ValueDecl *, 16> initializers;
2742-
if (CurrDeclContext->lookupQualified(type, DeclBaseName::createConstructor(),
2743-
NL_QualifiedDefault,
2744-
initializers)) {
2745-
for (auto *init : initializers) {
2746-
if (init->shouldHideFromEditor())
2747-
continue;
2748-
if (IsUnresolvedMember &&
2749-
cast<ConstructorDecl>(init)->isFailable() &&
2750-
!cast<ConstructorDecl>(init)->isImplicitlyUnwrappedOptional()) {
2751-
continue;
2752-
}
2753-
addConstructorCall(cast<ConstructorDecl>(init), Reason,
2754-
dynamicLookupInfo, type, None,
2755-
/*IsOnType=*/true, name);
2741+
2742+
auto results =
2743+
swift::lookupSemanticMember(const_cast<DeclContext *>(CurrDeclContext),
2744+
type, DeclBaseName::createConstructor());
2745+
for (const auto &entry : results.allResults()) {
2746+
auto *init = cast<ConstructorDecl>(entry.getValueDecl());
2747+
if (init->shouldHideFromEditor())
2748+
continue;
2749+
if (IsUnresolvedMember && init->isFailable() &&
2750+
!init->isImplicitlyUnwrappedOptional()) {
2751+
continue;
27562752
}
2753+
addConstructorCall(cast<ConstructorDecl>(init), Reason,
2754+
dynamicLookupInfo, type, None,
2755+
/*IsOnType=*/true, name);
27572756
}
27582757
}
27592758

lib/Sema/TypeChecker.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,8 @@ TypeChecker::getDeclTypeCheckingSemantics(ValueDecl *decl) {
711711
void swift::bindExtensions(SourceFile &SF) {
712712
::bindExtensions(SF);
713713
}
714+
715+
LookupResult
716+
swift::lookupSemanticMember(DeclContext *DC, Type ty, DeclName name) {
717+
return TypeChecker::lookupMember(DC, ty, name, None);
718+
}

0 commit comments

Comments
 (0)