You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/02/22 20:34:00 UTC

[jira] [Comment Edited] (GROOVY-9418) Why implicitly call of the inner class instance not allowed?

    [ https://issues.apache.org/jira/browse/GROOVY-9418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17042700#comment-17042700 ] 

Paul King edited comment on GROOVY-9418 at 2/22/20 8:33 PM:
------------------------------------------------------------

If you have the child object you can implicitly call it:
{code}
def ch = parent.child
ch()
{code}
Currently , missing method handling doesn't look whether an attempted method call could be a field/property which is callable.


was (Author: paulk):
If you have the child object you can implicitly call it:
{code}
def ch = parent.child
ch()
{code}
Currently , method missing handling doesn't look whether an attempted method call could be a field/property which is callable.

> Why implicitly call of the inner class instance not allowed?
> ------------------------------------------------------------
>
>                 Key: GROOVY-9418
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9418
>             Project: Groovy
>          Issue Type: Bug
>          Components: Groovy Console, groovy-runtime
>    Affects Versions: 2.4.18
>            Reporter: gekm
>            Priority: Major
>
> A parent and inner child classes:
> {code}
> class Parent {
>     def name
>     def child = new Child()
>     def call() {
>         println('parent called')
>     }
> }
> class Child {
>     def call() {
>         println('child called')
>    }
> }
> {code}
> Calling:
> {code}
> import base.Parent
> parent = new Parent(name: 'parent')
> parent()
> parent.child.call()
> parent.child()
> {code}
> output:
> {noformat}
> 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)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)