Skip to content

[5.3][CodeCompletion] Fast completion inside function builder function #32952

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 Jul 17, 2020

Cherry-pick of #32946 into release/5.3

  • Explanation: Fix an issue where fast-completion inside function builder function including accessor fails to work. This is because PreCheckFunctionBuilderRequest only use FunctionDecl as the cache key. Since fast-completion replaces the body of the function, the function decl alone is not sufficient for the key. Pass the body as well so that the request correctly evaluate the new body.
  • Scope: Code completion inside function builder function including inferred by protocol requirement
  • Risk: Low
  • Testing: Added regression test cases
  • Issue: rdar://problem/65692922
  • Reviewer: Robert Widmann (@CodaFi)

`PreCheckFunctionBuilderRequest` applies `PreCheckExpression` to the
expressions inside the function body. Previously it used to receive only
`AnyFunctionRef` (`FunctionDecl` or `ClosureExpr`) as the parameter.
However, when fast-completion kicks-in, it replaces the body of the
function, then tries to call `PreCheckFunctionBuilderRequest` again, with
the same function decl as before. It used to return cached "Success"
result, but it didn't actually apply `PreCheckExpression`. So any
`UnresolvedDeclRefExpr` remained unresolved.

In this patch, make `PreCheckFunctionBuilderRequest` receive "body" of the
function as well, so it doesn't return the cached result for the *previous*
body.

rdar://problem/65692922
(cherry picked from commit e953e52)
@rintaro rintaro added the r5.3 label Jul 17, 2020
@rintaro rintaro requested a review from a team as a code owner July 17, 2020 16:44
@rintaro
Copy link
Member Author

rintaro commented Jul 17, 2020

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Jul 17, 2020

@swift-ci Please nominate

@rintaro rintaro merged commit 9e57fbf into swiftlang:release/5.3 Jul 17, 2020
@rintaro rintaro deleted the 5.3-ide-completion-rdar65692922 branch July 17, 2020 19:24
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 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.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants