Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.3
-
None
-
None
Description
A regression affecting dynamic Groovy only (@CompileStatic code is not having this problem), a closure in a child class cannot call a static method in a parent class. This behavior was working at least as of 2.1.5.
Closures of a subclass can no longer access static methods of a super class in 2.3.3 dynamic Groovy, while they could in 2.1.5. Adding @CompileStatic to the "fails" method below is one possible workaround. Another workaround is to call the method explicitly as SuperClass.f.
class SuperClass { protected static f(String x) { x + " is super" } } class ChildClass extends SuperClass { public void doit() { println works() println fails() } private static def works() { f("Groovy") } private static def fails() { return {f("Groovy")}() } } new ChildClass().doit()
Result is "groovy is super" and then on the fails method:
groovy.lang.MissingMethodException: No signature of method: ChildClass$_fails_closure1.f() is applicable for argument types: (java.lang.String) values: [Groovy]
Possible solutions: is(java.lang.Object), is(java.lang.Object), any(), find(), any(), find()
Attachments
Issue Links
- relates to
-
GROOVY-5261 A static method call inside a static closure bypasses closure delegate behavior
- Closed