[nfc] allow ErrorTypeRepr to store a ZeroArgDiagnostic

There are sometimes parsing stuations where we don't want to
emit a parsing error, because of feature guarding. For
example, if a Feature involves new syntax for a type, we
must be able to parse both the true and false sides of an
ifdef guarding that new syntax based on a Feature flag.
This commit is contained in:
Kavon Farvardin
2023-11-12 21:54:55 -08:00
parent b598baf7f8
commit b55c4f1fc9
10 changed files with 58 additions and 23 deletions

View File

@@ -1053,7 +1053,7 @@ ParserResult<Pattern> Parser::parseTypedPattern() {
}
}
} else {
Ty = makeParserResult(new (Context) ErrorTypeRepr(PreviousLoc));
Ty = makeParserResult(ErrorTypeRepr::create(Context, PreviousLoc));
}
result = makeParserResult(result,
@@ -1278,7 +1278,7 @@ parseOptionalPatternTypeAnnotation(ParserResult<Pattern> result) {
TypeRepr *repr = Ty.getPtrOrNull();
if (!repr)
repr = new (Context) ErrorTypeRepr(PreviousLoc);
repr = ErrorTypeRepr::create(Context, PreviousLoc);
return makeParserResult(status, new (Context) TypedPattern(P, repr));
}