[swift-evolution] [Pitch] Require Any for existentials
antonyzhilin at gmail.com
Thu Aug 25 11:11:14 CDT 2016
Syntax for `T == P || T: P` is off-topic for current proposal, which is
just about replacing `P` with `Any<P>`.
Currently, equivalent of `Any<P>` has no subtypes (besides itself). This is
likely not going to be changed. So `where U : Any<P>` will not be allowed.
Generalized existentials also don't solve this problem. Existential
`Sequence` would look like this:
`Any<Sequence where Iterator.Element : P>`
Here, we can't accept `Iterator.Element == Any<P>` for the same reason that
we can't accept `Any<P> : P` in any other place: static member requirements
are not implemented.
To solve this problem, we should invent another generic requirement, say
`:==`, that prohibits calling static members on generic parameter. This
should be a separate proposal. `Any<P>` can't help here, because the
problem with calling static members only happens with static polymorphism.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution