Skip to content

[CodeCompletion] Call sawSolution when type checking a result builder #41846

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

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 16, 2022

Before, we weren’t calling sawSolution when performing solver based completion inside a result builder. That was no good because we always ended up in the fallback case.

This also contains some minor restructuring how solutions are filtered that I carried over from the argument-completion-to-solver-based PR.

@ahoppen ahoppen requested review from xedin and rintaro March 16, 2022 22:11
@ahoppen ahoppen force-pushed the pr/saw-solution-in-result-builder branch from 8408133 to 135c266 Compare March 16, 2022 22:17
@ahoppen
Copy link
Member Author

ahoppen commented Mar 16, 2022

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 16, 2022

@swift-ci Please SourceKit stress test

filterSolutionsForCodeCompletion(solutions, analyzer);
for (const auto &solution : solutions) {
cs.getASTContext().CompletionCallback->sawSolution(solution);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to just stop here instead of going farther and emitting diagnostics?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll try that in a follow-up PR because I’m curious to see if stopping early improves performance and if yes, by how much.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense regardless of performance impact because these diagnostics would just get emitted to be discarded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly want to know how big the performance win is. And I wanted to get this one merged to unblock the argument completion PR ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no worries, I'm not saying it should have been added in this PR, just want to make a point about it being logically correct thing to do :)

@ahoppen
Copy link
Member Author

ahoppen commented Mar 17, 2022

Wohooooooo 🎉 🥳 🎉

This fixes 1/3 of all known stress tester issues and improves code completion performance in slow cases by 10% - 20%

@ahoppen ahoppen merged commit ce2c771 into swiftlang:main Mar 17, 2022
ahoppen added a commit to ahoppen/swift-source-compat-suite that referenced this pull request Mar 17, 2022
The following issues have been fixed by swiftlang/swift#41846
- SR-14694 (partially)
- SR-14693
- SR-14704
- SR-14739
- SR-14889
- SR-14693
- SR-14693
ahoppen added a commit to ahoppen/swift-source-compat-suite that referenced this pull request Mar 17, 2022
The following issues have been fixed by swiftlang/swift#41846
- SR-14694 (partially)
- SR-14693
- SR-14704
- SR-14739
- SR-14889
- SR-14693
@ahoppen ahoppen deleted the pr/saw-solution-in-result-builder branch April 4, 2022 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants