Skip to content

[5.5][CodeCompletion] Reset 'hasSingleExpressionBody' when setting function body #37326

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

rintaro
Copy link
Member

@rintaro rintaro commented May 7, 2021

(Cherry-pick of #37324 into release/5.5)

  • Explanation: Fix a crash when fast-completion in a function body with multiple statements but if the user had done completions with single expression in the same body. Previously, fast-completion didn't reset hasSingleExpressionBody flag before setting the new body. Because of that, type checker tried to get the single expression from the non single expression body, which caused the crash
  • Scope: Code completion inside function bodies
  • Risk: Low
  • Testing: Added regression test to the suite
  • Issue: rdar://75358153
  • Reviewer: Ben Langmuir (@benlangmuir)

…n body

Previously, completing inside non single expression body might cause a
crash if you had done any completion with single expression in the same
body.

e.g.

  func test() {
    test(#^HERE^#)
  }

after that:

  func test() {
    test(arg)
    if #^HERE^#
  }

That was because the `hasSingleExpressionBody` wasn't cleared when
reusing the function for subsequent completions.

This patch just clears it whenever a new parsed body is set to a
function.

rdar://75358153
(cherry picked from commit 72f16df)
@rintaro rintaro requested a review from a team as a code owner May 7, 2021 21:31
@rintaro
Copy link
Member Author

rintaro commented May 7, 2021

@swift-ci Please test

@rintaro rintaro added the r5.5 label May 7, 2021
@akyrtzi akyrtzi merged commit ab8b0a5 into swiftlang:release/5.5 May 8, 2021
@rintaro rintaro deleted the 5.5-ide-completion-rdar75358153 branch May 10, 2021 19:00
@AnthonyLatsis AnthonyLatsis added swift 5.5 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants