Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5839

Typechecker does not detect shadowed generic parameter

    XMLWordPrintableJSON

Details

    Description

      The typechecker does not realize that the <T> of the method shadows the <T> of the class and compiles this code without warning. The same code does not typecheck in Java.

      public class GoodCodeRed<T> {
          Collection<GoodCodeRed<T>> attached
      
          @groovy.transform.CompileStatic
          public <T> void attach(GoodCodeRed<T> toAttach) {
              attached.add(toAttach)
          }
      }
      

      See also http://youtrack.jetbrains.com/issue/IDEA-96606

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              ddimitrov Dimitar Dimitrov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: