Even if it is covariant, you cannot change the return type of the interface. This is no different from covariance in non-general classes.
interface Animal { Animal GetAnimal(); } class Cat : Animal {
The problem is that C, as a specialization of B<C> returns C I<C>.GetT() , but J GetT() is required for the J specification.
Try the following:
interface I<out T> where T : class, I<T> { T GetT(); } interface J : I<J> { } abstract class B<T,U> : I<U> where T : B<T,U>, U where U : class, I<U> { U I<U>.GetT() { return null; } } class C : B<C,J>, J { }
source share