Associated Type Subtype Constraint


(Patrick Pijnappel) #1

Currently, it is not possible to constrain an associated type to a non-protocol, non-class type. I'm wondering about the technical reason for this, do we need to have a witness/vtable for that type at some point? Otherwise structs/enums would just trivially satisfy the subtyping requirement…


(Matthew Johnson) #2

I pitched the feature you’re looking for a little over a year ago: [Pitch] Generalized supertype constraints. Maybe after Swift 5 ships there is a chance of someone working on an implementation. We’ll have to wait and see...