@@ -1108,9 +1108,12 @@ static void parseGuardedPattern(Parser &P, GuardedPattern &result,
1108
1108
1109
1109
// If that didn't work, use a bogus pattern so that we can fill out
1110
1110
// the AST.
1111
- if (patternResult.isNull ())
1112
- patternResult =
1113
- makeParserErrorResult (new (P.Context ) AnyPattern (P.PreviousLoc ));
1111
+ if (patternResult.isNull ()) {
1112
+ auto *AP = new (P.Context ) AnyPattern (P.PreviousLoc );
1113
+ if (P.PreviousLoc .isInvalid ())
1114
+ AP->setImplicit ();
1115
+ patternResult = makeParserErrorResult (AP);
1116
+ }
1114
1117
1115
1118
// Fill in the pattern.
1116
1119
status |= patternResult;
@@ -1506,7 +1509,10 @@ Parser::parseStmtConditionElement(SmallVectorImpl<StmtConditionElement> &result,
1506
1509
1507
1510
if (ThePattern.isNull ()) {
1508
1511
// Recover by creating AnyPattern.
1509
- ThePattern = makeParserResult (new (Context) AnyPattern (PreviousLoc));
1512
+ auto *AP = new (Context) AnyPattern (PreviousLoc);
1513
+ if (PreviousLoc.isInvalid ())
1514
+ AP->setImplicit ();
1515
+ ThePattern = makeParserResult (AP);
1510
1516
}
1511
1517
1512
1518
// Conditional bindings must have an initializer.
@@ -2133,7 +2139,7 @@ ParserResult<Stmt> Parser::parseStmtForEach(LabeledStmtInfo LabelInfo) {
2133
2139
SourceLoc InLoc;
2134
2140
if (pattern.isNull ()) {
2135
2141
// Recover by creating a "_" pattern.
2136
- pattern = makeParserErrorResult (new (Context) AnyPattern ( SourceLoc () ));
2142
+ pattern = makeParserErrorResult (AnyPattern::createImplicit (Context ));
2137
2143
consumeIf (tok::kw_in, InLoc);
2138
2144
} else if (!IsCStyleFor) {
2139
2145
parseToken (tok::kw_in, InLoc, diag::expected_foreach_in);
@@ -2422,6 +2428,8 @@ parseStmtCaseDefault(Parser &P, SourceLoc &CaseLoc,
2422
2428
2423
2429
// Create an implicit AnyPattern to represent the default match.
2424
2430
auto Any = new (P.Context ) AnyPattern (CaseLoc);
2431
+ if (CaseLoc.isInvalid ())
2432
+ Any->setImplicit ();
2425
2433
LabelItems.push_back (
2426
2434
CaseLabelItem::getDefault (Any, WhereLoc, Guard.getPtrOrNull ()));
2427
2435
0 commit comments