method clash diagnostic does not distinguish between hiding and overriding

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Rejected
    • Priority: P4
    • None
    • Affects Version/s: 7
    • Component/s: tools
    • unknown
    • generic

      1) ************************************

      import java.util.List;

      class A {
      static String foo(List<Integer> l) {return null;}
      }

      class B extends A {
      static Integer foo(List<Integer> l) {return null;}
      }

      /usr/local/home/maurizio/Desktop/Test3.java:8: foo(java.util.List<java.lang.Integer>) in B cannot override foo(java.util.List<java.lang.Integer>) in A; attempting to use incompatible return type
               Integer foo(List<Integer> l) {return null;}
                       ^
        required: java.lang.String
        found: java.lang.Integer
      1 error

      (2) ************************************

      import java.util.List;

      class A {
      static String foo(List<Integer> l) {return null;}
      }

      class B extends A {
      static Integer foo(List<String> l) {return null;}
      }

      Test3.java:8: name clash: foo(java.util.List<java.lang.String>) in B and foo(java.util.List<java.lang.Integer>) in A have the same erasure, yet neither overrides the other
      static int foo(List<String> l) {return 0;}
      ^
      1 error

            Assignee:
            Unassigned
            Reporter:
            Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: