Uploaded image for project: 'SonarJava'
  1. SonarJava
  2. SONARJAVA-1589

Semantic: hiding static parametrized methods wrongly resolved

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.12
    • Component/s: Semantic
    • Labels:
      None

      Description

      Static and hiding parametrized methods are not resolved correctly when dealing with bounds of their variables.

      class HidingOfStaticMethod {
        static class A<T> {
          static <E> A<E> of(E e1, E e2) {
            return null;
          }
        }
        
        static class B<T> extends A<T> {
          static <E extends Comparable<? super E>> B<E> of(E e1, E e2) {
            return null;
          }
        }
        
        void tst() {
          A<String> a1 = A.of("hello", "world"); // explicit call to A.of()
          A<String> a2 = B.of("hello", "world"); // explicit call to B.of() - currently resolved to A.of()
          A<C> a3 = B.of(new C(), new C()); // call to inherited method A.of() through B
        }
      }
      

        Attachments

          Activity

            People

            • Assignee:
              michael.gumowski Michael Gumowski
              Reporter:
              michael.gumowski Michael Gumowski
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: