Skip to content

[5.4][CodeCompletion] Reset 'hasSingleExpressionBody' when setting function body #37493

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 18, 2021

Cherry-pick of #37324 into release/5.4

  • 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://78122363
  • 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)
(cherry picked from commit f104036)
@rintaro
Copy link
Member Author

rintaro commented May 18, 2021

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented May 18, 2021

@swift-ci Please nominate

@rintaro rintaro added the r5.4 label May 18, 2021
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0b13b05

@rintaro
Copy link
Member Author

rintaro commented May 19, 2021

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0b13b05

@rintaro
Copy link
Member Author

rintaro commented May 19, 2021

@swift-ci Please test Linux

@rintaro rintaro merged commit c446b9e into swiftlang:release/5.4 May 19, 2021
@rintaro rintaro deleted the 5.4-ide-completion-rdar75358153 branch May 19, 2021 15:41
@AnthonyLatsis AnthonyLatsis added swift 5.4 🍒 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants