Why implicitly call of the inner class instance not allowed? [duplicate]
I use groovy 2.4.18
A parent and inner child classes:
class Parent {
def name
def child = new Child()
def call() {
println('parent called')
}
class Child {
def call() {
println('child called')
}
}
}
Calling:
import base.Parent
parent = new Parent(name: 'parent')
parent()
parent.child.call()
parent.child()
output:
parent called
child called
Caught: groovy.lang.MissingMethodException: No signature of method: base.Parent.child() is applicable for argument types: () values: []
Possible solutions: call(), find(), find(groovy.lang.Closure), getChild(), setChild(java.lang.Object), split(groovy.lang.Closure)
This should be a bug. I am not 100% as we may have redefined when automatic expansion to call is valid (assigning child to a local variable x and then doing x() will work for example), but I would still suggest to enter an issue for this in the Apache Groovy JIRA.