@@ -665,19 +665,19 @@ Parser::TypeResult Parser::parseTypeIdentifier() {
665
665
if (startsWithLess (Tok)) {
666
666
SmallVector<TypeRepr *, 4 > GenericArgsAST;
667
667
SourceLoc LAngleLoc, RAngleLoc;
668
- auto GenericArgsResult = parseGenericArgumentClauseSyntax ();
668
+ auto GenericArgsResult =
669
+ parseGenericArgumentsAST (GenericArgsAST, LAngleLoc, RAngleLoc);
669
670
if (!GenericArgsResult.isSuccess ()) {
670
671
if (Base)
671
672
Junk.push_back (*Base);
672
673
if (Period)
673
674
Junk.push_back (*Period);
674
675
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);
679
679
}
680
- GenericArgs = GenericArgsResult. getResult ();
680
+ GenericArgs = SyntaxContext-> popIf <ParsedGenericArgumentClauseSyntax> ();
681
681
}
682
682
683
683
if (!Base)
@@ -1070,18 +1070,15 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
1070
1070
// Consume a name.
1071
1071
NameLoc = Tok.getLoc ();
1072
1072
Name = consumeArgumentLabelSyntax ();
1073
- LocalJunk.push_back (*Name);
1074
1073
1075
1074
// If there is a second name, consume it as well.
1076
1075
if (Tok.canBeArgumentLabel ()) {
1077
1076
SecondNameLoc = Tok.getLoc ();
1078
1077
SecondName = consumeArgumentLabelSyntax ();
1079
- LocalJunk.push_back (*SecondName);
1080
1078
}
1081
1079
1082
1080
// Consume the ':'.
1083
1081
if ((Colon = consumeTokenSyntaxIf (tok::colon))) {
1084
- LocalJunk.push_back (*Colon);
1085
1082
// If we succeed, then we successfully parsed a label.
1086
1083
if (Backtracking)
1087
1084
Backtracking->cancelBacktrack ();
@@ -1090,6 +1087,8 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
1090
1087
} else {
1091
1088
if (!Backtracking)
1092
1089
diagnose (Tok, diag::expected_parameter_colon);
1090
+ Name = None;
1091
+ SecondName = None;
1093
1092
NameLoc = SourceLoc ();
1094
1093
SecondNameLoc = SourceLoc ();
1095
1094
}
@@ -1100,14 +1099,20 @@ Parser::TypeResult Parser::parseTypeTupleBody() {
1100
1099
1101
1100
Backtracking.reset ();
1102
1101
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
+
1103
1109
// Parse the type annotation.
1104
1110
auto TypeLoc = Tok.getLoc ();
1105
1111
auto TypeASTResult = parseType (diag::expected_type);
1106
1112
if (TypeASTResult.hasCodeCompletion () || TypeASTResult.isNull ()) {
1107
- Junk.append (LocalJunk.begin (), LocalJunk.end ());
1108
- if (auto parsedT = SyntaxContext->popIf <ParsedTypeSyntax>())
1109
- Junk.push_back (*parsedT);
1110
1113
skipListUntilDeclRBraceSyntax (Junk, LParenLoc, tok::r_paren, tok::comma);
1114
+ for (auto &&Item : LocalJunk)
1115
+ Junk.push_back (Item);
1111
1116
return TypeASTResult.hasCodeCompletion ()
1112
1117
? makeParserCodeCompletionStatus ()
1113
1118
: makeParserError ();
0 commit comments