The review of SE-0194 has ended. The proposal is accepted with revisions. The specific changes to the proposal as reviewed are:
-
@objc
enums defined in Swift will receive automatic synthesis of the list of all cases. There is no technical basis for limiting synthesis to non-@objc
enums. Note that this change does not affect enums defined in (Objective-)C: Swift will (still) not synthesize the list of all cases for imported enums. -
Unavailable cases will not be listed, because values of an unavailable case cannot exist in a well-typed Swift program (in breaks the availability model).
-
Automatic synthesis is only provided when the conformance is stated on the
enum
definition (not an extension), following the precedent set byCodable
(SE-0167) andEquatable
/Hashable
synthesis (SE-0185). -
The protocol, associated type, and property are named
CaseIterable
,AllCases
, andallCases
, respectively. The core team felt that these names reflect the primary use case of this protocol, promoting better clarity for most code that iterates over all of the cases. We choseIterable
overEnumerable
becauseEnumerable
has some incorrect connotations (e.g., theenumerated()
method).
Thank you to the proposal authors and implementer, and everyone who participated in the review!
Doug