-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Filter overloads if their function application doesn't contain the code completion token #41917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeCompletion] Filter overloads if their function application doesn't contain the code completion token #41917
Conversation
@swift-ci Please smoke test |
@swift-ci Please SourceKit stress test |
lib/Sema/CSSimplify.cpp
Outdated
}; | ||
CodeCompletionTypeFinder CompletionTypeFinder; | ||
type.walk(CompletionTypeFinder); | ||
return CompletionTypeFinder.ContainsCodeCompletionTypeVar; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easier way of doing this would be to use type.findIf([&](Type type) { return isCodeCompetionTypeVar(type); });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing it think way you wouldn't need an additional isCodeCompletionTypeVar(fnTypeVar)
in your condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's fnTypeVar
, never mind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that’s definitely cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this makes sense, this is what I have advocated for at some point but the counter here is that some of the results are going to be lost because not all of the overloads of the chained members are going to be attempted...
I think this trade-off is reasonable. This change eliminates all timeouts in the stress tester + fixes some other expression to complex issues while barely introducing any new issues (I still need to investigate what the two unexpected failures are). |
Sounds good then :) |
4f0a0fa
to
99cc75b
Compare
@swift-ci Please smoke test |
@swift-ci Please smoke test Windows |
lib/Sema/CSSimplify.cpp
Outdated
if (isForCodeCompletion()) | ||
return false; | ||
if (isForCodeCompletion()) { | ||
bool ArgContainsCCTypeVar = Type(argFnType).findIf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that this could be simplified down to Type(argFnType).findIf(isCodeCompletionTypeVar);
…'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.
99cc75b
to
045302b
Compare
@swift-ci Please smoke test |
- SR-14694: A few timeout issues were resolved by swiftlang/swift#41917 and others were introduced by swiftlang/swift#41633. - SR-16012: A couple more cases were caused by migrating expression completions to solver-based swiftlang/swift#41633
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.