Skip to content

Commit 54f2aa3

Browse files
committed
[CodeCompletion] Tiny optimization for unresolved member compilation
* Early exit for operators * Early exit for equal types
1 parent 459e07f commit 54f2aa3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,6 +3789,9 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
37893789
// same result type) as the contextual type.
37903790
FilteredDeclConsumer consumer(*this, [=](ValueDecl *VD,
37913791
DeclVisibilityKind reason) {
3792+
if (VD->isOperator())
3793+
return false;
3794+
37923795
if (!VD->hasInterfaceType()) {
37933796
TypeResolver->resolveDeclSignature(VD);
37943797
if (!VD->hasInterfaceType())
@@ -3822,7 +3825,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
38223825
// convertible to the contextual type.
38233826
if (auto CD = dyn_cast<TypeDecl>(VD)) {
38243827
declTy = declTy->getMetatypeInstanceType();
3825-
return swift::isConvertibleTo(declTy, T, *DC);
3828+
return declTy->isEqual(T) || swift::isConvertibleTo(declTy, T, *DC);
38263829
}
38273830

38283831
// Only static member can be referenced.
@@ -3839,7 +3842,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
38393842
// FIXME: This emits just 'factory'. We should emit 'factory()' instead.
38403843
declTy = FT->getResult();
38413844
}
3842-
return swift::isConvertibleTo(declTy, T, *DC);
3845+
return declTy->isEqual(T) || swift::isConvertibleTo(declTy, T, *DC);
38433846
});
38443847

38453848
auto baseType = MetatypeType::get(T);

0 commit comments

Comments
 (0)