Confusing limitations on covariant overriding

You’ll find similar limitations on covariant method overrides as well. Only subclassing and optional injection is supported, not any other subtype relationships in the type system. This part of the language has not received much attention unfortunately. Swift 4 had a new implementation of method overrides that’s fixed various compiler crashes and miscompiles, but it did not change the underlying language rules. They’re still implemented in a one-off manner that only applies to method overrides.

4 Likes