Skip to content

Commit 71aa44d

Browse files
committed
Revert "Merge pull request swiftlang#26914 from rintaro/syntaxparse-genericargsyntax"
This reverts commit 0899eb6, reversing changes made to b8f42d6.
1 parent 149c875 commit 71aa44d

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

lib/Parse/ParseType.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -665,19 +665,19 @@ Parser::TypeResult Parser::parseTypeIdentifier() {
665665
if (startsWithLess(Tok)) {
666666
SmallVector<TypeRepr *, 4> GenericArgsAST;
667667
SourceLoc LAngleLoc, RAngleLoc;
668-
auto GenericArgsResult = parseGenericArgumentClauseSyntax();
668+
auto GenericArgsResult =
669+
parseGenericArgumentsAST(GenericArgsAST, LAngleLoc, RAngleLoc);
669670
if (!GenericArgsResult.isSuccess()) {
670671
if (Base)
671672
Junk.push_back(*Base);
672673
if (Period)
673674
Junk.push_back(*Period);
674675
Junk.push_back(*Identifier);
675-
auto genericJunks = GenericArgsResult.getUnknownNodes();
676-
Junk.append(genericJunks.begin(), genericJunks.end());
677-
return makeParsedResult<ParsedTypeSyntax>(
678-
Junk, GenericArgsResult.getStatus());
676+
if (auto GenericJunk = SyntaxContext->popIf<ParsedSyntax>())
677+
Junk.push_back(*GenericJunk);
678+
return makeParsedResult<ParsedTypeSyntax>(Junk, GenericArgsResult);
679679
}
680-
GenericArgs = GenericArgsResult.getResult();
680+
GenericArgs = SyntaxContext->popIf<ParsedGenericArgumentClauseSyntax>();
681681
}
682682

683683
if (!Base)
@@ -1070,18 +1070,15 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
10701070
// Consume a name.
10711071
NameLoc = Tok.getLoc();
10721072
Name = consumeArgumentLabelSyntax();
1073-
LocalJunk.push_back(*Name);
10741073

10751074
// If there is a second name, consume it as well.
10761075
if (Tok.canBeArgumentLabel()) {
10771076
SecondNameLoc = Tok.getLoc();
10781077
SecondName = consumeArgumentLabelSyntax();
1079-
LocalJunk.push_back(*SecondName);
10801078
}
10811079

10821080
// Consume the ':'.
10831081
if ((Colon = consumeTokenSyntaxIf(tok::colon))) {
1084-
LocalJunk.push_back(*Colon);
10851082
// If we succeed, then we successfully parsed a label.
10861083
if (Backtracking)
10871084
Backtracking->cancelBacktrack();
@@ -1090,6 +1087,8 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
10901087
} else {
10911088
if (!Backtracking)
10921089
diagnose(Tok, diag::expected_parameter_colon);
1090+
Name = None;
1091+
SecondName = None;
10931092
NameLoc = SourceLoc();
10941093
SecondNameLoc = SourceLoc();
10951094
}
@@ -1100,14 +1099,20 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
11001099

11011100
Backtracking.reset();
11021101

1102+
if (Name)
1103+
LocalJunk.push_back(*Name);
1104+
if (SecondName)
1105+
LocalJunk.push_back(*SecondName);
1106+
if (Colon)
1107+
LocalJunk.push_back(*Colon);
1108+
11031109
// Parse the type annotation.
11041110
auto TypeLoc = Tok.getLoc();
11051111
auto TypeASTResult = parseType(diag::expected_type);
11061112
if (TypeASTResult.hasCodeCompletion() || TypeASTResult.isNull()) {
1107-
Junk.append(LocalJunk.begin(), LocalJunk.end());
1108-
if (auto parsedT = SyntaxContext->popIf<ParsedTypeSyntax>())
1109-
Junk.push_back(*parsedT);
11101113
skipListUntilDeclRBraceSyntax(Junk, LParenLoc, tok::r_paren, tok::comma);
1114+
for (auto &&Item : LocalJunk)
1115+
Junk.push_back(Item);
11111116
return TypeASTResult.hasCodeCompletion()
11121117
? makeParserCodeCompletionStatus()
11131118
: makeParserError();

test/Syntax/round_trip_misc.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@ class C {
44
// Erroneous typealias decl.
55
typealias Inner: Foo = Int
66

7-
typealias Alias1 = [Generic<Int
8-
7+
typealias Inner: Foo2 = [Generic<Int
98

109
// Implict accessor with attribute at the top of its body.
1110
var x: Int {
1211
@objc
1312
func f() {}
1413
}
1514
}
16-
do {
17-
typealias Alias2 = () -> (a b: [Generic<Int
18-
}
19-
do {
20-
typealias Alias3 = (a b C,
21-
}
2215

2316
// Orphan '}' at top level
2417
}

0 commit comments

Comments
 (0)