Skip to content

Commit b1802fa

Browse files
committed
[Concurrency] Minor fixes for parsing and syntax of 'async'
1 parent 84f4cc0 commit b1802fa

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

lib/Parse/ParsePattern.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -785,19 +785,12 @@ Parser::parseFunctionSignature(Identifier SimpleName,
785785
defaultArgs);
786786
FullName = DeclName(Context, SimpleName, NamePieces);
787787

788-
// Check for the 'async' keyword.
789-
if (Context.LangOpts.EnableExperimentalConcurrency &&
790-
Tok.isContextualKeyword("async")) {
791-
asyncLoc = consumeToken();
792-
}
793-
794788
// Check for the 'async' and 'throws' keywords.
795789
rethrows = false;
796790
parseAsyncThrows(SourceLoc(), asyncLoc, throwsLoc, &rethrows);
797791

798-
SourceLoc arrowLoc;
799-
800792
// If there's a trailing arrow, parse the rest as the result type.
793+
SourceLoc arrowLoc;
801794
if (Tok.isAny(tok::arrow, tok::colon)) {
802795
SyntaxParsingContext ReturnCtx(SyntaxContext, SyntaxKind::ReturnClause);
803796
if (!consumeIf(tok::arrow, arrowLoc)) {
@@ -817,14 +810,14 @@ Parser::parseFunctionSignature(Identifier SimpleName,
817810
Status |= ResultType;
818811
if (Status.isError())
819812
return Status;
813+
814+
// Check for 'throws' and 'rethrows' after the type and correct it.
815+
parseAsyncThrows(arrowLoc, asyncLoc, throwsLoc, &rethrows);
820816
} else {
821817
// Otherwise, we leave retType null.
822818
retType = nullptr;
823819
}
824820

825-
// Check for 'throws' and 'rethrows' after the type and correct it.
826-
parseAsyncThrows(arrowLoc, asyncLoc, throwsLoc, &rethrows);
827-
828821
return Status;
829822
}
830823

tools/swift-syntax-test/swift-syntax-test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ int parseFile(
610610
Invocation.getLangOptions().VerifySyntaxTree = options::VerifySyntaxTree;
611611
Invocation.getLangOptions().RequestEvaluatorGraphVizPath = options::GraphVisPath;
612612
Invocation.getLangOptions().DisablePoundIfEvaluation = true;
613+
Invocation.getLangOptions().EnableExperimentalConcurrency = true;
613614

614615
Invocation.getFrontendOptions().InputsAndOutputs.addInputFile(InputFileName);
615616

utils/gyb_syntax_support/DeclNodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
Node('FunctionSignature', kind='Syntax',
7777
children=[
7878
Child('Input', kind='ParameterClause'),
79-
Child('AsyncKeyword', kind='Token', text_choices=['async'],
80-
is_optional=True),
79+
Child('AsyncKeyword', kind='ContextualKeywordToken',
80+
text_choices=['async'], is_optional=True),
8181
Child('ThrowsOrRethrowsKeyword', kind='Token',
8282
is_optional=True,
8383
token_choices=[

utils/gyb_syntax_support/ExprNodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@
183183
# NOTE: This appears only in SequenceExpr.
184184
Node('ArrowExpr', kind='Expr',
185185
children=[
186-
Child('AsyncKeyword', kind='Token', text_choices=['async'],
187-
is_optional=True),
186+
Child('AsyncKeyword', kind='ContextualKeywordToken',
187+
text_choices=['async'], is_optional=True),
188188
Child('ThrowsToken', kind='ThrowsToken',
189189
is_optional=True),
190190
Child('ArrowToken', kind='ArrowToken'),

0 commit comments

Comments
 (0)