File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -5270,7 +5270,9 @@ class EnumElementDecl : public ValueDecl {
5270
5270
static_cast <unsigned >(ElementRecursiveness::NotRecursive);
5271
5271
}
5272
5272
5273
- void computeType ();
5273
+ // / \returns false if there was an error during the computation rendering the
5274
+ // / EnumElementDecl invalid, true otherwise.
5275
+ bool computeType ();
5274
5276
5275
5277
bool hasArgumentType () const { return !ArgumentType.getType ().isNull (); }
5276
5278
Type getArgumentType () const { return ArgumentType.getType (); }
Original file line number Diff line number Diff line change @@ -4309,7 +4309,7 @@ SourceRange EnumElementDecl::getSourceRange() const {
4309
4309
return {getStartLoc (), getNameLoc ()};
4310
4310
}
4311
4311
4312
- void EnumElementDecl::computeType () {
4312
+ bool EnumElementDecl::computeType () {
4313
4313
EnumDecl *ED = getParentEnum ();
4314
4314
4315
4315
Type resultTy = ED->getDeclaredTypeInContext ();
@@ -4326,6 +4326,7 @@ void EnumElementDecl::computeType() {
4326
4326
resultTy = FunctionType::get (argTy, resultTy);
4327
4327
4328
4328
setType (resultTy);
4329
+ return true ;
4329
4330
}
4330
4331
4331
4332
Type EnumElementDecl::getArgumentInterfaceType () const {
Original file line number Diff line number Diff line change @@ -5543,11 +5543,14 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
5543
5543
EED->setRecursiveness (ElementRecursiveness::NotRecursive);
5544
5544
}
5545
5545
5546
- // Now that we have an argument type we can set the element's declared
5547
- // type.
5548
- if (!EED->hasType ())
5549
- EED->computeType ();
5550
- EED->setIsBeingTypeChecked (false );
5546
+ {
5547
+ defer { EED->setIsBeingTypeChecked (false ); };
5548
+
5549
+ // Now that we have an argument type we can set the element's declared
5550
+ // type.
5551
+ if (!EED->hasType () && !EED->computeType ())
5552
+ return ;
5553
+ }
5551
5554
5552
5555
// Test for type parameters, as opposed to a generic decl context, in
5553
5556
// case the enclosing enum type was illegally declared inside of a generic
You can’t perform that action at this time.
0 commit comments