Skip to content

[Syntax] Consolidate 'TupleElement' and 'FunctionCallArgument' kinds #27564

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,7 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc At
/*isPostfix=*/false, /*isExprBasic=*/true,
lParenLoc, args, argLabels, argLabelLocs,
rParenLoc, trailingClosure,
SyntaxKind::FunctionCallArgumentList);
SyntaxKind::TupleExprElementList);
assert(!trailingClosure && "Cannot parse a trailing closure here");
hasInitializer = true;
}
Expand Down
21 changes: 10 additions & 11 deletions lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
tok::l_square, tok::r_square,
/*isPostfix=*/true, isExprBasic, lSquareLoc, indexArgs,
indexArgLabels, indexArgLabelLocs, rSquareLoc, trailingClosure,
SyntaxKind::FunctionCallArgumentList);
SyntaxKind::TupleExprElementList);
Result = makeParserResult(
status | Result,
SubscriptExpr::create(Context, Result.get(), lSquareLoc, indexArgs,
Expand All @@ -1140,7 +1140,7 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,

// Add dummy blank argument list to the call expression syntax.
SyntaxContext->addSyntax(
ParsedSyntaxRecorder::makeBlankFunctionCallArgumentList(
ParsedSyntaxRecorder::makeBlankTupleExprElementList(
Tok.getLoc(), *SyntaxContext));

ParserResult<Expr> closure =
Expand Down Expand Up @@ -1590,7 +1590,7 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
argLabelLocs,
rParenLoc,
trailingClosure,
SyntaxKind::FunctionCallArgumentList);
SyntaxKind::TupleExprElementList);
SyntaxContext->createNodeInPlace(SyntaxKind::FunctionCallExpr);
return makeParserResult(
status,
Expand All @@ -1605,7 +1605,7 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
if (Tok.is(tok::l_brace) && isValidTrailingClosure(isExprBasic, *this)) {
// Add dummy blank argument list to the call expression syntax.
SyntaxContext->addSyntax(
ParsedSyntaxRecorder::makeBlankFunctionCallArgumentList(
ParsedSyntaxRecorder::makeBlankTupleExprElementList(
Tok.getLoc(), *SyntaxContext));

ParserResult<Expr> closure =
Expand Down Expand Up @@ -1639,7 +1639,7 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
// element without label.
ExprContext.setCreateSyntax(SyntaxKind::TupleExpr);
return parseExprList(tok::l_paren, tok::r_paren,
SyntaxKind::TupleElementList);
SyntaxKind::TupleExprElementList);

case tok::l_square:
return parseExprCollection();
Expand Down Expand Up @@ -3015,8 +3015,7 @@ ParserStatus Parser::parseExprList(tok leftTok, tok rightTok,
SubExpr = new(Context) UnresolvedDeclRefExpr(OperName,
DeclRefKind::Ordinary,
DeclNameLoc(Loc));
} else if (Kind == SyntaxKind::FunctionCallArgumentList &&
Tok.is(tok::code_complete)) {
} else if (isPostfix && Tok.is(tok::code_complete)) {
// Handle call arguments specially because it may need argument labels.
auto CCExpr = new (Context) CodeCompletionExpr(Tok.getLoc());
if (CodeCompletion)
Expand Down Expand Up @@ -3131,7 +3130,7 @@ Parser::parseExprObjectLiteral(ObjectLiteralExpr::LiteralKind LitKind,
argLabelLocs,
rParenLoc,
trailingClosure,
SyntaxKind::FunctionCallArgumentList);
SyntaxKind::TupleExprElementList);
if (status.hasCodeCompletion())
return makeParserCodeCompletionResult<Expr>();
if (status.isError())
Expand Down Expand Up @@ -3170,9 +3169,9 @@ ParserResult<Expr> Parser::parseExprPoundUnknown(SourceLoc LSquareLoc) {
// Parse arguments.
ParserStatus status =
parseExprList(tok::l_paren, tok::r_paren,
/*isPostfix=*/false, /*isExprBasic*/ false, LParenLoc,
/*isPostfix=*/true, /*isExprBasic*/ true, LParenLoc,
args, argLabels, argLabelLocs, RParenLoc, trailingClosure,
SyntaxKind::FunctionCallArgumentList);
SyntaxKind::TupleExprElementList);
if (status.hasCodeCompletion())
return makeParserCodeCompletionResult<Expr>();
if (status.isError())
Expand Down Expand Up @@ -3288,7 +3287,7 @@ Parser::parseExprCallSuffix(ParserResult<Expr> fn, bool isExprBasic) {
argLabelLocs,
rParenLoc,
trailingClosure,
SyntaxKind::FunctionCallArgumentList);
SyntaxKind::TupleExprElementList);

// Form the call.
return makeParserResult(
Expand Down
6 changes: 2 additions & 4 deletions lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,14 +1299,12 @@ SourceLoc Parser::getErrorOrMissingLoc() const {

static SyntaxKind getListElementKind(SyntaxKind ListKind) {
switch (ListKind) {
case SyntaxKind::FunctionCallArgumentList:
return SyntaxKind::FunctionCallArgument;
case SyntaxKind::TupleExprElementList:
return SyntaxKind::TupleExprElement;
case SyntaxKind::ArrayElementList:
return SyntaxKind::ArrayElement;
case SyntaxKind::DictionaryElementList:
return SyntaxKind::DictionaryElement;
case SyntaxKind::TupleElementList:
return SyntaxKind::TupleElement;
case SyntaxKind::FunctionParameterList:
return SyntaxKind::FunctionParameter;
case SyntaxKind::TupleTypeElementList:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public </DeclModifier>class Foo<TypeInheritanceClause>: <InheritedType><SimpleTy
public </DeclModifier>subscript<ParameterClause>(<FunctionParameter>k: <SimpleTypeIdentifier>Int </SimpleTypeIdentifier><InitializerClause>= <SuperRefExpr>super</SuperRefExpr></InitializerClause></FunctionParameter>) </ParameterClause><ReturnClause>-> <SimpleTypeIdentifier>Int </SimpleTypeIdentifier></ReturnClause><AccessorBlock>{ <AccessorDecl>get </AccessorDecl>}</AccessorBlock></SubscriptDecl></MemberDeclListItem><MemberDeclListItem><FunctionDecl><DeclModifier>
public </DeclModifier>func foo<FunctionSignature><ParameterClause>(<FunctionParameter>x: <SimpleTypeIdentifier>Int </SimpleTypeIdentifier><InitializerClause>= <SuperRefExpr>super</SuperRefExpr></InitializerClause></FunctionParameter>)</ParameterClause></FunctionSignature></FunctionDecl></MemberDeclListItem><MemberDeclListItem><FunctionDecl><DeclModifier>
public </DeclModifier>func foo<FunctionSignature><ParameterClause>(<FunctionParameter>y: <SimpleTypeIdentifier>Int </SimpleTypeIdentifier><InitializerClause>= <MemberAccessExpr><SuperRefExpr>super</SuperRefExpr>.init</MemberAccessExpr></InitializerClause></FunctionParameter>)</ParameterClause></FunctionSignature></FunctionDecl></MemberDeclListItem><MemberDeclListItem><FunctionDecl><DeclModifier>
public </DeclModifier>func foo<FunctionSignature><ParameterClause>(<FunctionParameter>z: <SimpleTypeIdentifier>Int </SimpleTypeIdentifier><InitializerClause>= <SubscriptExpr><SuperRefExpr>super</SuperRefExpr>[<FunctionCallArgument><IntegerLiteralExpr>1</IntegerLiteralExpr></FunctionCallArgument>]</SubscriptExpr></InitializerClause></FunctionParameter>)</ParameterClause></FunctionSignature></FunctionDecl></MemberDeclListItem>
public </DeclModifier>func foo<FunctionSignature><ParameterClause>(<FunctionParameter>z: <SimpleTypeIdentifier>Int </SimpleTypeIdentifier><InitializerClause>= <SubscriptExpr><SuperRefExpr>super</SuperRefExpr>[<TupleExprElement><IntegerLiteralExpr>1</IntegerLiteralExpr></TupleExprElement>]</SubscriptExpr></InitializerClause></FunctionParameter>)</ParameterClause></FunctionSignature></FunctionDecl></MemberDeclListItem>
}</MemberDeclBlock></ClassDecl>
Loading