Skip to content

Commit abb864d

Browse files
committed
naming changes
1 parent b576a40 commit abb864d

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,8 +3209,8 @@ ERROR(unsupported_recursive_struct,none,
32093209
"contains it",
32103210
(Type))
32113211

3212-
WARNING(enum_not_constructible,none,
3213-
"enum containing only recursive cases is not constructible", ())
3212+
WARNING(enum_non_well_founded,none,
3213+
"enum containing only recursive cases is impossible to instantiate", ())
32143214
ERROR(recursive_enum_not_indirect,none,
32153215
"recursive enum %0 is not marked 'indirect'", (Type))
32163216
ERROR(unsupported_infinitely_sized_type,none,

lib/Sema/TypeCheckCircularity.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class CircularityChecker {
169169
bool diagnoseInfiniteRecursion(CanType parentType, ValueDecl *member,
170170
CanType memberType);
171171

172-
void diagnoseNotConstructible(EnumDecl *E);
172+
void diagnoseNonWellFoundedEnum(EnumDecl *E);
173173

174174
void addPathElementsTo(Path &path, CanType type);
175175
void addPathElement(Path &path, ValueDecl *member, CanType memberType);
@@ -275,7 +275,8 @@ bool CircularityChecker::expandEnum(CanType type, EnumDecl *E,
275275
unsigned depth) {
276276
// Indirect enums are representational leaves.
277277
if (E->isIndirect()) {
278-
diagnoseNotConstructible(E);
278+
// Diagnose whether the enum is non-well-founded before bailing
279+
diagnoseNonWellFoundedEnum(E);
279280
return false;
280281
}
281282

@@ -303,7 +304,7 @@ bool CircularityChecker::expandEnum(CanType type, EnumDecl *E,
303304
if (addMember(type, elt, eltType, depth))
304305
return true;
305306
}
306-
diagnoseNotConstructible(E);
307+
diagnoseNonWellFoundedEnum(E);
307308

308309
return false;
309310
}
@@ -608,9 +609,10 @@ bool CircularityChecker::diagnoseInfiniteRecursion(CanType parentType,
608609
return true;
609610
}
610611

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) {
614616

615617
auto containsType = [](TupleType *tuple, Type E) -> bool {
616618
for (auto type: tuple->getElementTypes()) {
@@ -619,7 +621,7 @@ void CircularityChecker::diagnoseNotConstructible(EnumDecl *E) {
619621
}
620622
return false;
621623
};
622-
auto isNotConstructible = [containsType, E]() -> bool {
624+
auto isNonWellFounded = [containsType, E]() -> bool {
623625
auto elts = E->getAllElements();
624626
if (elts.empty())
625627
return false;
@@ -644,6 +646,6 @@ void CircularityChecker::diagnoseNotConstructible(EnumDecl *E) {
644646
return true;
645647
};
646648

647-
if (isNotConstructible())
648-
TC.diagnose(E, diag::enum_not_constructible);
649+
if (isNonWellFounded())
650+
TC.diagnose(E, diag::enum_non_well_founded);
649651
}

test/Sema/unsupported_recursive_value_type.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ enum RecursiveByGenericSubstitutionEnum<T> {
4242
case A(T)
4343
}
4444

45-
enum InconstructibleEnum1 { // expected-warning {{enum containing only recursive cases is not constructible}}
45+
enum InconstructibleEnum1 { // expected-warning {{enum containing only recursive cases is impossible to instantiate}}
4646
indirect case A(InconstructibleEnum1)
4747
}
4848
enum InconstructibleEnum2 { // OK
4949
indirect case A(InconstructibleEnum2)
5050
case B(Bool)
5151
indirect case C(Int, InconstructibleEnum2)
5252
}
53-
enum InconstructibleEnum3 { // expected-warning {{enum containing only recursive cases is not constructible}}
53+
enum InconstructibleEnum3 { // expected-warning {{enum containing only recursive cases is impossible to instantiate}}
5454
indirect case B(Int, InconstructibleEnum3)
5555
}
56-
indirect enum InconstructibleEnum4 { // expected-warning {{enum containing only recursive cases is not constructible}}
56+
indirect enum InconstructibleEnum4 {
57+
// expected-warning@-1 {{enum containing only recursive cases is impossible to instantiate}}
5758
case A(InconstructibleEnum4)
5859
}
59-
indirect enum InconstructibleEnum5 { // expected-warning {{enum containing only recursive cases is not constructible}}
60+
indirect enum InconstructibleEnum5 {
61+
// expected-warning@-1 {{enum containing only recursive cases is impossible to instantiate}}
6062
case B(Int, InconstructibleEnum5)
6163
}
6264
indirect enum InconstructibleEnum6 { // OK

0 commit comments

Comments
 (0)