Skip to content

Commit b8f5bf3

Browse files
committed
[CodeCompletion][Parse] Don't drop the contained expression when completing 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
1 parent cb6b1ea commit b8f5bf3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ ParserResult<Expr> Parser::parseExprUnary(Diag<> Message, bool isExprBasic) {
533533

534534
ParserResult<Expr> SubExpr = parseExprUnary(Message, isExprBasic);
535535
if (SubExpr.hasCodeCompletion())
536-
return makeParserCodeCompletionResult<Expr>();
536+
return makeParserCodeCompletionResult<Expr>(SubExpr.getPtrOrNull());
537537
if (SubExpr.isNull())
538538
return nullptr;
539539
return makeParserResult(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename %s
2+
3+
if undefined(&self.#^COMPLETE^#

0 commit comments

Comments
 (0)