Is there a reason why a method with a more specific type cannot implement an interface with a less specific one?
public interface IInterface<out T>
{
T GetValues();
}
public class Class : IInterface<object>
{
public Class GetValuesSubType() => null;
//public object GetValues() => GetValuesSubType();
// This won't compile:
public Class GetValues() => null;
}
As the method returning the same values is perfectly valid code with only upcasting.
Is it a by design or is it just a "missing" feature?
EDIT:
It might actually be supported in C#7: https://github.com/dotnet/roslyn/issues/357