I didn't mention it explicitly but this use case should work, since @unknown default:
is a variation of default:
. Put another way, a default:
clause is required, but if one adds @unknown
, then it would behave analogous to how @unknown
behaves in other situations; it should warn about any cases that are accessible but not explicitly written.
I understand the use case for testing. However, conformances for externally defined protocols need to be public, so it gives a very easy way for clients to create/iterate over non-public cases, which may be undesirable. My impression from Matthew's prior pitch was that this was unappealing. Certainly open to removing this restriction though.
One potential workaround if you're using only internal
cases is that you could hand-write a retroactive conformance in the test suite after doing a @testable import
; that would prevent library clients from accessing the conformance, while allowing the conformance to be used for easier testing. That's still more clunky though than the alternative of having compiler-synthesized conformances.