Davide Ancona writes:
9.4.1 Inheritance and Overriding: "It is possible for an interface to inherit several methods with override-equivalent signatures (��8.4.2). Such a situation does not in itself cause a compile-time error. The interface is considered to inherit all the methods. However, *A* one of the inherited methods must must be return type substitutable for any other inherited method; otherwise, a compile-time error occurs (The throws clauses do not cause errors in this case.)"
8.4.8.4 Inheriting Methods with Override-Equivalent Signatures: "If all the inherited methods are abstract, then the class is necessarily an abstract class and is considered to inherit all the abstract methods. A compile-time error occurs *B* if, for any two such inherited methods, one of the methods is not return type substitutable for the other (The throws clauses do not cause errors in this case.)"
What seems quite bizarre to us is that the condition *B* for type-safe inheritance of methods with override-equivalent signatures for abstract classes is strictly stronger than condition *A* for interfaces.
We have tried to compile the following program:
interface T1 extends T2,T3{}
interface T2{}
interface T3{}
interface I1{ T1 m(); }
interface I2{ T2 m(); }
interface I3{ T3 m(); }
interface I extends I1,I2,I3{}
Despite in this case condition *A* is verified, the compiler (1.6.0_06) detects the following error:
exceptions.java:17: types I3 and I2 are incompatible; both define m(), but with unrelated return types
interface I extends I1,I2,I3{}