Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8074570

Javac does not get membership right when it comes to erased supertypes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 7-pool, 8, 9
    • tools
    • None

      This program fails to compile:

      interface Sup<X> {
          boolean m(X x);
      }

      interface Sub<X> extends Sup<String> {
          boolean m(String s);
      }

      class Test {
          void test() {
              Sub s = new Sub() {
                  @Override
                  public boolean m(String o) { return true; }
              };
          }

      Compiler says:

      Main.java:15: error: <anonymous Test$1> is not abstract and does not override abstract method m(Object) in Sup
              Sub s2 = new Sub() {
                                 ^
      1 error

      This seems to be inconsistent with the notion that 'overridden methods should not be inherited'.

      Note: this also affect the functional interface check as of JDK 8.

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: