[swift-evolution] Class and Subclass Existentials (Round 2)
hooman at mac.com
Tue Feb 14 13:30:45 CST 2017
> On Feb 14, 2017, at 1:24 AM, Slava Pestov via swift-evolution <swift-evolution at swift.org> wrote:
>> 3. When a protocol composition type contains a typealias, the validity of the type is determined using the following steps:
>> Expand the typealias
>> Normalize the type by removing duplicate constraints and replacing less specific constraints by more specific constraints (a class constraint is less specific than a class type constraint, which is less specific than a constraint of a subclass of that class).
>> Check that the type does not contain two class-type constraints
> You could generalize this and instead say that if the type contains two class-type constraints, the resulting existential type is the common base class of the two classes, or AnyObject if they do not share a common base class.
Why would we do that? They are called constraints, and we use “&” between them. They should move towards the more specific subclass, not the less restrained base class. So, I would say:
If the type contains two class-type constraints, it is only acceptable if one class constrain is a subclass of the other and the resulting constrain will be the subclass.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution