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

Closure taking Object[] in @CompileStatic class gets actual parameters wrapped in additional Object[]

    XMLWordPrintableJSON

Details

    Description

      @groovy.transform.CompileStatic
      class MyClass {
        void method() {
          final cl = { Object[] args -> println "cl: ${args}" }
          cl('c1-1', 'c1-2')
        }
      }
      
      class MyClass2 {
        void method() {
          final cl = { Object[] args -> println "cl2: ${args}" }
          cl('c1-1', 'c1-2')
        }
      }
      
      new MyClass().method()
      new MyClass2().method()
      

      Produces the output:

      cl: [[c1-1, c1-2]]
      cl2: [c1-1, c1-2]
      

      indicating that the Closure in the statically-compiled MyClass is receiving the arguments wrapped in an additional Object[].

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            acourtneybrown Adam Brown
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: