It has the following interface:
public interface ICovariant<out T>
{
public void InputFunc(Func<T> func);
}
I get the following compile-time error:
Invalid variance: covariant type parameter 'T' is used in contravariant position. Parameter must be input-safe
The location of Func<T> is input. Func<T> is Func<out T>, so it is output.
OK, I was wrong. Get information that location is relevant.
However, when I add the following method, an error occurs.
public interface ICovariant<out T>
{
public void InputFunc(Func<T> func);
public Action<T> ReturnAction();
}
Invalid variance: covariant type parameter 'T' is used in contravariant position. Method return type must be output-safe
The location of Action<T> is the output. Action<T> is Action<in T>, so it is input.
what? Unlike before, this time the location doesn't matter.
Why do the two examples perceive each other differently?