You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: accepted/2.17/enhanced-enums/feature-specification.md
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -64,9 +64,11 @@ It is a **compile-time error** to refer to a declared or default generative cons
64
64
* As the target of a redirecting generative constructor of the same `enum` declaration (`: this(...);`/`: this.targetName(...);`), or
65
65
* Implicitly in the enum value declarations of the same `enum` (`enumValueName(args)`/`enumValueName.targetName(args)`).
66
66
67
-
_No-one is allowed to invoke a generative constructor and create an instance of the `enum` other than the enumerated enum values.
68
-
That also means that a redirecting *factory* constructor cannot redirect to a generative constructor of an `enum`,
69
-
and therefore no factory constructor of an `enum` declaration can be `const`, because a `const` factory constructor must redirect to a generative constructor._
67
+
_No-one is allowed to invoke a generative constructor and create an instance of the `enum` other than the enumerated enum values._
68
+
69
+
It is a **compile-time error** if the constructor implicitly invoked by an enumerated enum value declaration is a factory constructor.
70
+
71
+
_A redirecting factory constructor can redirect to a generative constructor of an `extension type`, which may in turn return one of the existing values of that `enum`. This must be an error, because the enumerated values of an `enum` declaration must be distinct._
70
72
71
73
It's a **compile-time error** if the enum declaration contains a static or instance member declaration with the name `values`, or if the superclass or any superinterface of the enum declaration has an interface member named `values`. _A `values` static constant member will be provided for the class, this restriction ensures that there is no conflict with that declaration._
72
74
@@ -460,3 +462,5 @@ There is a chance that people will start using `enum` declarations to declare si
460
462
1.7, 2022-02-16: Disallow overriding `operator==` and `hashCode` too.
461
463
1.8, 2022-03-08: Make it explicit that an enum constructor cannot use the new super-parameters.
462
464
1.9, 2023-01-13: Adjust the grammar to allow enum entry using `new` to specify a constructor.
465
+
1.10, 2023-11-10: Add an error about factory constructors: They can not be used
0 commit comments