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

Incorrectly processing method-level type generics information

    XMLWordPrintableJSON

Details

    Description

      import static java.util.Arrays.asList
      
      @groovy.transform.CompileStatic
      class Main {
          final <T> Iterable<T> foo(T instance) { asList(instance) }
          // next line fails with: [Static type checking] - Cannot call <T> java.util.Arrays#asList(T[]) with arguments [U]
          final <U> Iterable<U> bar(U instance) { asList(instance) }
          final Iterable<String> baz(String instance) { asList(instance) }
      }
      
      new Main().with {
          assert foo('A') + bar('B') + baz('C') == ['A', 'B', 'C']
      }
      

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: