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

WildcardTree should be a TypeTree and give access to its associated symbolType

    Details

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

      Description

      Current WildcardTree is not a TypeTree, and consequently have no type directly associated. However, for each WildcardTree we are actually computing a type during semantic analysis. This type is only used for the parent Parametrized type, and not associated to the WildcardTree itself.

      It should be possible to access to its type directly from the tree, instead of having to go through the parent ParametrizedTypeTree, or the symbol associated to the bound, and then infer from the bound type.

      From a Java Language perspective, we can not define variables using a WildcardTree directly as type (? extends Foo myVar;), but we can still add annotations, like in any other TypeTree as we defined them.

      import java.lang.annotation.ElementType;
      import java.lang.annotation.Target;
      import java.util.List;
      
      abstract class A {
        abstract void foo(List<@Foo ? extends B> myList);
      }
      
      class B { }
      
      @Target(value = ElementType.TYPE_USE)
      @interface Foo { }
      

      In the previous example, we should be able to subscribe to directly access the wildcard tree, and get its type directly.

        Attachments

          Issue Links

            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: