In general case, this problem has no correct solution, for the same reasons as why (any P)
does not conform to P
.
There are few hacky self-conforming protocols, including Error
. We might continue to support hacks for Error
, and say that A1 | A2 | ... | An
conforms to Error
is every A
i conforms to Error
.
But in general case, we should not be trying to solve this "problem". Instead,
A. Even without union type conforming to protocol, you can still:
- access common members (even without common protocol or base class)
- upcast to common existential type or base class
- open unions like existentials (similar to SE-0352, or, if we ever get explicit opening, it should work for unions too).
B. If you need to express constraint over generic type, which can be concrete type, existential or union, then you need Existential subtyping as generic constraint.