Skip to content

[CodeCompletion][Parse] Don't drop the contained expression when completing within an InOutExpr #36738

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
Apr 6, 2021

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Apr 3, 2021

When completing within an InOutExpr like &foo.<complete>, we were forming a CodeCompletionExpr with a base when parsing the content of the InOutExpr and storing it in CodeCompletionCallbacksImpl::CodeCompleteTokenExpr. Whenever the result of that parse contained a code completion though, we were dropping it completely and returning an empty code completion ParseResult in place of the inout expression, which resulted in later code inserting a different CodeCompletionExpr into the AST that had no base expression. The solver-based completion implementation would later ask for the type of the CodeCompletionExpr and its base using the expression stored in CodeCompletionCallbacksImpl::CodeCompleteTokenExpr, but that never actually ended up in the AST, resulting in an assertion hit about the expression not having a type in the formed solution(s).

Resolves rdar://75366814

…leting within an InOutExpr

When completing within an InOutExpr like `&foo.<complete>`, we were forming a
CodeCompletionExpr with a base when parsing the content of the InOutExpr and
storing it in CodeCompletionCallbacksImpl::CodeCompleteTokenExpr. When the
result of that parse contained a code completion though, we were dropping the
sub-expression completely and forming an empty code completion result in place
of the inout expression, which resulted in later code inserting a code
completion expression with no base into the AST. The solver based completion
was later asking for the type of the code completion and its base using the
expression stored in CodeCompletionCallbacksImpl::CodeCompleteTokenExpr, but
that never ended up in the AST so we hit an assertion about the expression not
have a type in the formed solutions.

Resolves rdar://75366814
@nathawes nathawes requested review from xedin and rintaro April 3, 2021 04:22
@nathawes
Copy link
Contributor Author

nathawes commented Apr 3, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Apr 3, 2021

Build failed
Swift Test OS X Platform
Git Sha - b8f5bf3

@nathawes
Copy link
Contributor Author

nathawes commented Apr 6, 2021

@swift-ci please test macOS

@nathawes nathawes merged commit 927c709 into swiftlang:main Apr 6, 2021
@nathawes nathawes deleted the fix-completion-crash branch April 6, 2021 05:54
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.

4 participants