Skip to content

[CodeCompletion] Avoid prechecking twice when typeCheckForCodeCompletion is given a non-applicable expression (NFC) #34518

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

Conversation

nathawes
Copy link
Contributor

For code completion within a multi-statement closure, typeCheckExpression will be called on the expression containing the closure, and potentially again on the expression within the closure body that contains the completion location.
In the first call, the typeCheckForCodeCompletion pre-checks the expression as part of determining whether a second call is going to be made (in which case the first is not applicable for completion purposes) or not. In the case where it's not applicable control is returned to the regular typeCheckExpression code path, which would then pre-check the expression again.

This just moves the pre-check in typeCheckExpression before the call out to typeCheckForCodeCompletion, and passes a bool to typeCheckForCodeCompletion to tell it not to pre-check. typeCheckForCodeCompletion still needs to support pre-checking for fallback cases when no separate typeCheckExpression call will be made due to errors in the outer expression, or when no typeCheckExpression call is made at all.

…ion is given a non-applicable expression (NFC)

For code completion within a multi-statement closure, typeCheckExpression will
be called on the expression containing the closure, and potentially again on
the expression within the closure body that contains the completion location.
In the first call, the typeCheckForCodeCompletion pre-checks the expression as
part of determining whether a second call is going to be made (in which case
the first is not applicable for completion purposes) or not. In the case where
it's not applicable control is returned to the regular typeCheckExpression
code path, which would then precheck the expression again.

This just moves the precheck before the call out to typeCheckForCodeCompletion
so we avoid prechecking twice unecessarily.
@nathawes nathawes requested a review from xedin October 30, 2020 18:01
@nathawes
Copy link
Contributor Author

@swift-ci please test

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.

LGTM!

@nathawes
Copy link
Contributor Author

nathawes commented Nov 2, 2020

@swift-ci please test and merge

@swift-ci swift-ci merged commit c36a302 into swiftlang:main Nov 2, 2020
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.

3 participants