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

Closure meta class respondsTo(closure, "doCall") does not work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.7, 1.5.8
    • 1.7.2, 1.8-beta-1
    • None
    • None
    • Only tested for Groovy 1.5.7 and 1.5.8 since i am unable to compile the project with groovy 1.8.0

    Description

      When running the following code:

      Closure test =

      {String x -> println x}

      ;
      println test.metaClass.respondsTo(test, "doCall");

      The resulting output is: []

      Which is incorrect, since the MOP for respondsTo(Object, String) states:
      [...] if the implementing MetaClass responds to a method with the given name regardless of arguments.
      But the Closure does respond to doCall(String), which can easily be verified using this code:

      println test.metaClass.respondsTo(test, "doCall", "Hello");

      which will output something similar to: [public MyClass$_myMethod_closure1.doCall(java.lang.String)]
      which tells us, that the closure does respond to doCall(String).

      Hence, this meta method, and all other meta methods named doCall - regardless of their parameters - aswell, should also be included in the list returned by respondsTo(Object,String).

      Attachments

        1. 4038_v18x_Patch.txt
          3 kB
          Roshan Dawrani

        Activity

          People

            roshandawrani Roshan Dawrani
            misterd Joscha Drechsler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: