Here is my inheritance that I’m dealing with:
interface IInputable<T> {}
interface IOutputable<U> {}
interface IStepIO<T, U> : IInputable<T>, IOutputable<U> {}
class Step<T, U> : IStepIO<T, U> {}
class Sequence<T, U> : Step<T, U> {}
class RuleSequence: Sequence<Graph, Graph> {}
If I create a new RuleSequence, I’m expecting to be able to pass it back in a method that returns IStepIO<Graph, Graph>, but I get a compiler warning that I cannot implicitly do that conversion. Something about my understanding of this situation is off because I was thinking that should work and I can’t wrap my head around why it doesn’t. Please note that I can’t make the generic types co or contra variant because I have a getter setter in both IInputable and IOutputable which uses the generic type. If someone can explain this to me like I’m 5, it would be very much appreciated. Thank you!