Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.0-JSR-6
-
None
-
Fails in both scripts and classes
Description
While it's possible to call static methods from other static methods in the same class, as shown in the next example:
groovy> static foo()
{ println "foo" }groovy> static bar() { foo() }
groovy> bar()
groovy> go
foo
but if we're inside a closure in a static method, we can't call other static methods. The following example illustrates the problem:
groovy> static foo() { println "foo" }
groovy> static bar() { 1.times
{ foo() } }
groovy> bar()
groovy> go
Caught: groovy.lang.MissingMethodException: No signature of method CommandLine$_bar_closure1.foo() is applicable for argument types: () values: {}
at CommandLine$_bar_closure1.doCall(CommandLine.groovy:2)
at gjdk.java.lang.Number_GroovyReflector.invoke(Unknown Source)
at CommandLine.bar(CommandLine.groovy:2)
at gjdk.CommandLine_GroovyReflector.invoke(Unknown Source)
at CommandLine.run(CommandLine.groovy:3)
Ooops