Skip to content

[CodeComplete] Fall back to typechecking a single expression result builder doesn't typecheck #37709

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 31, 2021

If a result builder body fails to typecheck, we currently don't provide any code completion results at all. Instead, try to recover by type checking the expression in the result builder that contains the code completion token, on its own.

I know this is a bit of a hack and that we might be missing some information about contextual types, but IMHO this is preferable than not providing any results at all.

Resolves rdar://78015510

@ahoppen ahoppen requested review from xedin and rintaro May 31, 2021 13:08
@ahoppen
Copy link
Member Author

ahoppen commented May 31, 2021

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented May 31, 2021

@swift-ci Please SourceKit Stress Test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ede10bf711f10585bbe77789498f3ba4e0cf0238

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Makes sense to me! You might want to mark the comment as a FIXME: though since the fix here would be to partially resolve result builder bodies to preserve contextual information for code completion, which is a much bigger change on a type-checker side...

…uilder doesn't typecheck

If a result builder body fails to typecheck, we currently don't provide any code completion results at all. Instead, try to recovery by type checking the expression in the result builder that conatins the code completion token on its own. This might be missing some information about contextual types but is preferrable over not providing any results at all.

Resolves rdar://78015510
@ahoppen ahoppen force-pushed the pr/fallback-typecheck-result-builder branch from ede10bf to 583ed8d Compare May 31, 2021 19:18
@ahoppen
Copy link
Member Author

ahoppen commented May 31, 2021

Verified that there is no performance regression in code completion using the stress tester’s performance measurement capabilities.

@xedin Good idea. I changed the comment slightly.

@ahoppen
Copy link
Member Author

ahoppen commented May 31, 2021

@swift-ci Please test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

Thank you!

@ahoppen ahoppen merged commit b443118 into swiftlang:main Jun 3, 2021
@ahoppen ahoppen deleted the pr/fallback-typecheck-result-builder branch July 5, 2021 09:18
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.

4 participants