Skip to content

[CodeCompletion] Allow preChecking an expression twice in code completion #38474

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
Jul 28, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 19, 2021

In code completion we might call preCheckExpression twice - once for the first pass and once for the second pass. This is fine since preCheckExpression idempotent, so don't assert if we are in code completion mode.

Fixes rdar://79136653 [SR-14755]

@ahoppen ahoppen requested a review from rintaro July 19, 2021 16:59
@ahoppen
Copy link
Member Author

ahoppen commented Jul 20, 2021

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Jul 20, 2021

@xedin Should preCheckExpression() be idempotent (#33749 (comment))?

@xedin
Copy link
Contributor

xedin commented Jul 20, 2021

I think it should be yes, although there might be edge cases which cases these crashes...

@xedin
Copy link
Contributor

xedin commented Jul 20, 2021

Is this some kind of a stale pointer problem where sequence has been folded but something still holds a reference to an original version?

@rintaro
Copy link
Member

rintaro commented Jul 20, 2021

@rintaro
Copy link
Member

rintaro commented Jul 20, 2021

Maybe we can just disable these assertions (!expr->isFolded()) when we are in code completion mode?

@xedin
Copy link
Contributor

xedin commented Jul 20, 2021

I think it would be okay. Real solution here would be to type-check multi-statement closures together with their context just like single-expression ones, once that's done we should be able to remove all this complicated fallback logic.

…tion

In code completion we might call `preCheckExpression` twice - once for the first pass and once for the second pass. This is fine since `preCheckExpression` idempotent, so don't assert if we are in code completion mode.

Fixes rdar://79136653 [SR-14755]
@ahoppen ahoppen force-pushed the pr/dont-precheck-twice branch from a8ae0a6 to 202905f Compare July 21, 2021 09:18
@ahoppen
Copy link
Member Author

ahoppen commented Jul 21, 2021

OK, that’s the even simpler fix. I disabled the asserts if CompletionCallback is set.

@ahoppen
Copy link
Member Author

ahoppen commented Jul 21, 2021

@swift-ci Please smoke test

@ahoppen ahoppen changed the title [CodeCompletion] Make sure to not pre-check an expression a second time in fallback completion [CodeCompletion] Allow preChecking an expression twice in code completion Jul 21, 2021
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