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

Static generic method invocation with explicitely stated type doesn't compile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.2
    • 1.7.3, 1.8-beta-1
    • Compiler
    • None
    • Groovy Version: 1.7.2 JVM: 1.6.0_12
      Running in Debian lenny amd64 with linux kernel 2.6.32

    Description

      Cannot compile statements like SomeClass.<Integer>create(). Example code:

      Test.groovy
      class Test<E> {
              E someVariable;
      
              protected Test() {
              }
      
              public static <E> Test<E> create() {
                      return new Test<E>();
              }
      
              public static void main(String[] args) {
                      Test<Integer> t = Test.<Integer>create();
              }
      }
      

      The error is:

      $ groovy Test.groovy
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      /home/aless/Test.groovy: 12: Unknown type: TYPE_ARGUMENTS at line: 12 column: 26. File: /home/aless/Test.groovy @ line 12, column 26.
                      Test<Integer> t = Test.<Integer>create();
                                  ^
      
      1 error
      

      Exactly the same file (with a .java extension) compiles with javac.

      Attachments

        1. v3_4190_v18x_Patch.txt
          6 kB
          Roshan Dawrani
        2. v2_4190_v18x_Patch.txt
          5 kB
          Roshan Dawrani
        3. 4190_v18x_Patch.txt
          0.7 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            aless Ales Smodis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: