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