I have a protocol in which a function is defined, the return type of the function is SuperclassType .
In a class that conforms to the protocol, I am trying to define this function, but with a return type of SubclassType .
The compiler tells me that this class is not protocol compliant, because obviously SubclassType ! = SuperclassType
protocol SomeProtocol { func someFunction(someParameter:SomeType) -> SuperclassType? } class SomeClass : SomeProtocol { func someFunction(someParameter:SomeType) -> SubclassType? { ... } } class SubclassType : SuperclassType { }
Common sense tells me that SubclassType should be a suitable replacement for SuperclassType in this matter.
What am I doing wrong?
Thanks.
source share