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

Static method not found when called from within closure in child class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.7, 2.2.1
    • 2.4.0-beta-4
    • groovy-runtime
    • None

    Description

      As of groovy 2.1.7, a static method is not found when it is called from within a closure in a child class.

      Example:

      class Superclass {
          static SuperclassStaticMethod() {
              return "A"
          }
      }
      
      class Closureclass extends Superclass {
          static closuremethod = {
              return "B" + SuperclassStaticMethod() // this should be found
          }
      }
      
      assert Closureclass.closuremethod() == "BA"

      Before groovy 2.1.7, this would work fine. As of groovy 2.1.7, including 2.2.1, this will result in a:

      groovy.lang.MissingMethodException: No signature of method: Closureclass$_clinit_closure1.SuperclassStaticMethod() is applicable for argument types: () values: []
      at Closureclass$_clinit_closure1.doCall(closureSimple.groovy:9)
      at Closureclass$_clinit_closure1.doCall(closureSimple.groovy)
      at closureSimple.run(closureSimple.groovy:13)

      I suspect https://jira.codehaus.org/browse/GROOVY-5261 (Fix Version/s: 2.1.7, 2.2.0-beta-2) may be a cause.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            ket Kevin Tunstall
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: