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

No argument invocation fails for closure with variable argument list.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.5.6, 1.6-beta-1
    • 1.5.7, 1.6-beta-2
    • None
    • None

    Description

      Not sure if this is a bug, but at least it is inconsistent.

      According to the documentation, calling a closure with no arguments is equivalent to calling it with one argument of null. So this works as expected:

      def f =

      {a -> print(a)}

      ; f() // prints null

      However,

      def f =

      {a, Object[] rest -> print(a)}; f()

      fails with
      groovy.lang.MissingMethodException: No signature of method: test$_run_closure1.call() is applicable for argument types: () values: {}

      What's inconsistent is that

      def f = {a, Object[] rest -> print(a)}

      ; f(null)

      prints "null" just fine.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            athiel Alexander Thiel
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: