mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Parse] Set ErrorType to invalid ParamDecl
TypeChecker assumes invalid decl has valid type. https://bugs.swift.org/browse/SR-8475 rdar://problem/43057057
This commit is contained in:
@@ -431,6 +431,14 @@ mapParsedParameters(Parser &parser,
|
||||
paramNameLoc, paramName, Type(),
|
||||
parser.CurDeclContext);
|
||||
param->getAttrs() = paramInfo.Attrs;
|
||||
|
||||
auto setInvalid = [&]{
|
||||
if (param->isInvalid())
|
||||
return;
|
||||
param->getTypeLoc().setInvalidType(ctx);
|
||||
param->setInvalid();
|
||||
};
|
||||
|
||||
bool parsingEnumElt
|
||||
= (paramContext == Parser::ParameterContextKind::EnumElement);
|
||||
// If we're not parsing an enum case, lack of a SourceLoc for both
|
||||
@@ -440,7 +448,7 @@ mapParsedParameters(Parser &parser,
|
||||
|
||||
// If we diagnosed this parameter as a parse error, propagate to the decl.
|
||||
if (paramInfo.isInvalid)
|
||||
param->setInvalid();
|
||||
setInvalid();
|
||||
|
||||
// If a type was provided, create the type for the parameter.
|
||||
if (auto type = paramInfo.Type) {
|
||||
@@ -464,8 +472,7 @@ mapParsedParameters(Parser &parser,
|
||||
if (!param->isInvalid())
|
||||
parser.diagnose(param->getLoc(), diag::missing_parameter_type);
|
||||
|
||||
param->getTypeLoc() = TypeLoc::withoutLoc(ErrorType::get(ctx));
|
||||
param->setInvalid();
|
||||
setInvalid();
|
||||
} else if (paramInfo.SpecifierLoc.isValid()) {
|
||||
StringRef specifier;
|
||||
switch (paramInfo.SpecifierKind) {
|
||||
|
||||
Reference in New Issue
Block a user