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

Incorrect resolution of methods in generic classes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.6
    • Component/s: Semantic
    • Labels:
      None

      Description

      class GenericClass<T extends Collection<Object>> {
        private ComplexNestedGenericClass(T argument);
        private void genericMethod(T argument);
      }
      
      public void test() {
        new NestedGenericClass<List<Object>>(new java.util.ArrayList<Object>())
          .genericMethod(new LinkedList<Object>());
        new ComplexNestedGenericClass<List<Object>>(new ArrayList<Object>())
        .genericMethod(new java.util.LinkedList<Object>());
      }
      

      Resolution fails if Collection is parameterized:
      T extends Collection -> fine
      T extends Collection<Object> -> fails

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              massimo.paladin Massimo PALADIN
              Reporter:
              samuel.mercier Samuel Mercier (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: