Skip to content

Commit 045302b

Browse files
committed
[CodeCompletion] Filter overloads if their function application doesn't contain the code completion token
When solving for code completion, we weren't disabling overloads because the call might be malfored in the presence of a code completion token (because the user is only now writing the function call). But this logic doesn't apply to function calls that don't even involve the code completion token, which happens if completing in result builders. I am hoping that this significantly improves code completion performance inside result builders.
1 parent 17ac201 commit 045302b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10771,8 +10771,12 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl(
1077110771
// Don't attempt to filter overloads when solving for code completion
1077210772
// because presence of code completion token means that any call
1077310773
// could be malformed e.g. missing arguments e.g. `foo([.#^MEMBER^#`
10774-
if (isForCodeCompletion())
10775-
return false;
10774+
if (isForCodeCompletion()) {
10775+
bool ArgContainsCCTypeVar = Type(argFnType).findIf(isCodeCompletionTypeVar);
10776+
if (ArgContainsCCTypeVar || isCodeCompletionTypeVar(fnTypeVar)) {
10777+
return false;
10778+
}
10779+
}
1077610780

1077710781
if (shouldAttemptFixes()) {
1077810782
auto arguments = argFnType->getParams();

0 commit comments

Comments
 (0)