File tree Expand file tree Collapse file tree 5 files changed +22
-9
lines changed
validation-test/compiler_crashers_fixed Expand file tree Collapse file tree 5 files changed +22
-9
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,10 +4309,15 @@ 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
-
4315
4314
Type resultTy = ED->getDeclaredTypeInContext ();
4315
+
4316
+ if (resultTy->is <ErrorType>()) {
4317
+ setType (resultTy);
4318
+ return false ;
4319
+ }
4320
+
4316
4321
Type argTy = MetatypeType::get (resultTy);
4317
4322
4318
4323
// The type of the enum element is either (T) -> T or (T) -> ArgType -> T.
@@ -4326,6 +4331,7 @@ void EnumElementDecl::computeType() {
4326
4331
resultTy = FunctionType::get (argTy, resultTy);
4327
4332
4328
4333
setType (resultTy);
4334
+ return true ;
4329
4335
}
4330
4336
4331
4337
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
Original file line number Diff line number Diff line change @@ -334,3 +334,5 @@ struct UnsolvableInheritance1<T : T.A> {}
334
334
struct UnsolvableInheritance2 < T : U . A , U : T . A > { }
335
335
// expected-error@-1 {{inheritance from non-protocol, non-class type 'U.A'}}
336
336
// expected-error@-2 {{inheritance from non-protocol, non-class type 'T.A'}}
337
+
338
+ enum X7 < T where X7. X : G > { case X } // expected-error{{'X' is not a member type of 'X7<T>'}}
Original file line number Diff line number Diff line change 5
5
// See http://swift.org/LICENSE.txt for license information
6
6
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
7
7
8
- // RUN: not --crash %target-swift-frontend %s -parse
8
+ // RUN: not %target-swift-frontend %s -parse
9
9
// REQUIRES: asserts
10
10
{ enum S< T where S. c: A { case c
You can’t perform that action at this time.
0 commit comments