@@ -169,7 +169,7 @@ class CircularityChecker {
169
169
bool diagnoseInfiniteRecursion (CanType parentType, ValueDecl *member,
170
170
CanType memberType);
171
171
172
- void diagnoseNotConstructible (EnumDecl *E);
172
+ void diagnoseNonWellFoundedEnum (EnumDecl *E);
173
173
174
174
void addPathElementsTo (Path &path, CanType type);
175
175
void addPathElement (Path &path, ValueDecl *member, CanType memberType);
@@ -275,7 +275,8 @@ bool CircularityChecker::expandEnum(CanType type, EnumDecl *E,
275
275
unsigned depth) {
276
276
// Indirect enums are representational leaves.
277
277
if (E->isIndirect ()) {
278
- diagnoseNotConstructible (E);
278
+ // Diagnose whether the enum is non-well-founded before bailing
279
+ diagnoseNonWellFoundedEnum (E);
279
280
return false ;
280
281
}
281
282
@@ -303,7 +304,7 @@ bool CircularityChecker::expandEnum(CanType type, EnumDecl *E,
303
304
if (addMember (type, elt, eltType, depth))
304
305
return true ;
305
306
}
306
- diagnoseNotConstructible (E);
307
+ diagnoseNonWellFoundedEnum (E);
307
308
308
309
return false ;
309
310
}
@@ -608,9 +609,10 @@ bool CircularityChecker::diagnoseInfiniteRecursion(CanType parentType,
608
609
return true ;
609
610
}
610
611
611
- // / Show a warning if the enum is not constructible. The outcome of this method
612
- // / is irrelevant.
613
- void CircularityChecker::diagnoseNotConstructible (EnumDecl *E) {
612
+ // / Show a warning if all cases of the given enum are recursive,
613
+ // / making it impossible to be instantiated. Such an enum is 'non-well-founded'.
614
+ // / The outcome of this method is irrelevant.
615
+ void CircularityChecker::diagnoseNonWellFoundedEnum (EnumDecl *E) {
614
616
615
617
auto containsType = [](TupleType *tuple, Type E) -> bool {
616
618
for (auto type: tuple->getElementTypes ()) {
@@ -619,7 +621,7 @@ void CircularityChecker::diagnoseNotConstructible(EnumDecl *E) {
619
621
}
620
622
return false ;
621
623
};
622
- auto isNotConstructible = [containsType, E]() -> bool {
624
+ auto isNonWellFounded = [containsType, E]() -> bool {
623
625
auto elts = E->getAllElements ();
624
626
if (elts.empty ())
625
627
return false ;
@@ -644,6 +646,6 @@ void CircularityChecker::diagnoseNotConstructible(EnumDecl *E) {
644
646
return true ;
645
647
};
646
648
647
- if (isNotConstructible ())
648
- TC.diagnose (E, diag::enum_not_constructible );
649
+ if (isNonWellFounded ())
650
+ TC.diagnose (E, diag::enum_non_well_founded );
649
651
}
0 commit comments