> On Feb 14, 2017, at 1:24 AM, Slava Pestov via swift-evolution > <[email protected]> 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.
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
