Skip to content

[CodeCompletion] Reset 'hasSingleExpressionBody' when setting function body #37324

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 7, 2021

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 flag 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

@rintaro
Copy link
Member Author

rintaro commented May 7, 2021

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir May 7, 2021 20:20
@rintaro rintaro marked this pull request as draft May 7, 2021 20:29
…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
@rintaro rintaro force-pushed the ide-completion-rdar75358153 branch from 443a0d2 to 72f16df Compare May 7, 2021 20:59
@rintaro
Copy link
Member Author

rintaro commented May 7, 2021

@swift-ci Please smoke test

@rintaro rintaro marked this pull request as ready for review May 7, 2021 21:01
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.

2 participants