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

Problem With Arguments Passed To Static Dynamic Methods

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.8
    • 2.4.0
    • groovy-runtime
    • None

    Description

      If I do something like this...

      String.metaClass.doSomething = { Object[] args ->
          println args.length
      }
      
      'Scott Gorham'.doSomething(1, 2, 3)
      

      args.length is 3, which is what I would expect.

      If I do something like this...

      String.metaClass.static.doSomething = { Object[] args ->
          println args.length
          println args[0].length
      }
      
      String.doSomething(1, 2, 3)
      

      Then args.length is 1 and args[0].length is 3. The array that contains the actual arguments (1, 2, 3) is being wrapped inside of another array.

      The instance method is behaving the way I would expect. The static method is not. It seems like these should behave the same with respect to this.

      Attachments

        Activity

          People

            Unassigned Unassigned
            brownj Jeff Brown
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: