JDK-6656332 : Problem with interfaces and covariant return type overriding
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2008-01-29
  • Updated: 2010-09-29
  • Resolved: 2008-01-29
Related Reports
Relates :  
Description
This test cannot be compiled:
---------------------------------------------------------------------------------------
/*
 * @test @(#)T9999999.java
 * @bug 9999999
 * @compile T9999999.java
 * @summary
 */
public class T9999999 {
    interface A {
        A m();
    }

    interface B extends A {
        B m();
    }

    interface C extends A {
        C m();
    }

    interface D extends B,C {
        D m();
    }

}
---------------------------------------------------------------------------------------

Using revision 1:e4dae1993f8b from
http://hg.openjdk.java.net/jdk7/jdk7/langtools

See also NetBeans bug:
http://www.netbeans.org/issues/show_bug.cgi?id=126054

Comments
EVALUATION D.m() overrides both C.m() and B.m(). So no compiler error should be raised since D.m() is return type substitutable for both B.m() and C.m(), since D <: C and D <: B (JLS 9.4.1).
11-02-2008