I have a class like SomeController<A where A: ProtA>
I have some subclasses of type SubController: SomeController<SubA>
Here is a working example of how I am trying to enter validation:
protocol SomeProtocol { } class SuperClass<A where A: SomeProtocol> { } class SubProtocol: SomeProtocol { } class SubClass: SuperClass<SubProtocol> { } func classTest<A where A: SomeProtocol>(classToTest: SuperClass<A>) { switch classToTest { case is SubClass:
Functionally, the code does exactly what I want, however I am left with a ton of warnings saying Cast from SuperClass<A> to SubClass always fails
Itโs clear that the types are related, and obviously the code works fine and doesnโt โalways failโ, so this warning seems to be wrong. Is this the current constraint or edge case of the type system, or is there a way to make the warning go away?
source share