covariant

covariant return type

$10.3/5 "The return type of an overriding function shall be either identical to the return type of the overridden function or covariant with the classes of the functions. If a function D::f overrides a function B::f, the return types of the functions are covariant if they satisfy the following criteria: — both a...

Why doesn't Java 5+ API take advantage of covariant return types?

Since Java 5 we are allowed to have covariant return types. Why doesn't the Java API take advantage of this? Take Graphics2D.create() for instance. Why isn't it overridden to return a Graphics2D object? It seems to me that it would be backward compatible in all situations. ...

C# Generic Covariant Error

following is my code, i don't know why DateTime can not change to Object , any idea to resolve this problem? public class Test { public DateTime CreatedTime { get; set; } } public class Test1 { } public class Test2 : Test1 { } static void Main(string[] args) { Func<Test...