Skip to content

Commit 35871c2

Browse files
committed
[CodeCompletion] Fix assertion failure if completing in a macro call argument
rdar://106966610
1 parent 6f67a3c commit 35871c2

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3391,8 +3391,6 @@ ParserResult<Expr> Parser::parseExprMacroExpansion(bool isExprBasic) {
33913391
if (Tok.isFollowingLParen()) {
33923392
auto result = parseArgumentList(tok::l_paren, tok::r_paren, isExprBasic,
33933393
/*allowTrailingClosure*/ true);
3394-
if (result.hasCodeCompletion())
3395-
return makeParserCodeCompletionResult<Expr>();
33963394
argList = result.getPtrOrNull();
33973395
status |= result;
33983396
} else if (Tok.is(tok::l_brace) &&

test/IDE/complete_call_arg.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,3 +1419,22 @@ func testRdar89773376(arry: [Int]) {
14191419
// RDAR89773376-DAG: Decl[Constructor]/CurrNominal/Flair[ArgLabels]: ['(']{#intVal: Int#}[')'][#Rdar89773376#];
14201420
// RDAR89773376: End completions
14211421
}
1422+
1423+
// This is an incomplete macro definition but it's sufficient to get the signature for code completion purposes
1424+
@freestanding(expression)
1425+
macro MyMacro(myArg: Int)
1426+
1427+
func testMacroCallPattern() {
1428+
#MyMacro(#^MACRO_CALL_PATTERN^#
1429+
// MACRO_CALL_PATTERN: Begin completions, 1 items
1430+
// MACRO_CALL_PATTERN: Pattern/CurrModule/Flair[ArgLabels]: ['(']{#myArg: Int#}[')'][#Void#]; name=myArg:
1431+
// MACRO_CALL_PATTERN: End completions
1432+
}
1433+
1434+
func testMacroArg() {
1435+
#MyMacro(myArg: #^MACRO_CALL_ARG^#
1436+
// MACRO_CALL_ARG: Begin completions
1437+
// MACRO_CALL_ARG-DAG: Literal[Integer]/None/TypeRelation[Convertible]: 0[#Int#]; name=0
1438+
// MACRO_CALL_ARG-DAG: Literal[Boolean]/None: true[#Bool#]; name=true
1439+
// MACRO_CALL_ARG: End completions
1440+
}

0 commit comments

Comments
 (0)