[Accepted] SE-0280: Enum Cases as Protocol Witnesses

The review of SE-0280: Enum Cases as Protocol Witnesses has concluded. Almost all of the feedback we received was in favor of making this change, and the Core Team is convinced that this closes an unnecessary semantic gap between enums and other types.

Some reviewers pointed out that, from a library-evolution perspective, it isn't possible to resiliently change a conformance from an enum case to an ordinary method or vice-versa. While this is true, it's also a direct consequence of a more general semantic property: the details of exactly how a type conforms to a protocol are always exposed to clients. For example, clients know whether a type provides a method directly or whether it picks up a "default implementation" from a protocol extension, and generic devirtualization will produce a direct call to the known implementation. Furthermore, the breadth of this issue will likely grow over time as protocol witnesses are permitted to differ more substantially from their requirement in signature. So while this is indeed arguably a flaw in Swift's current library-evolution design, it is something that needs to be addressed holistically, and there's no reason for it to block this proposal.

Accordingly, SE-0280 is accepted.

As always, thank you for your contribution to Swift.

John McCall
Review Manager

Terms of Service

Privacy Policy

Cookie Policy