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 2022/02/03 22:53:00 UTC

[jira] [Closed] (GROOVY-7375) Incorrect closure owner inside anonymous inner class

     [ https://issues.apache.org/jira/browse/GROOVY-7375?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-7375.
-----------------------------

> Incorrect closure owner inside anonymous inner class
> ----------------------------------------------------
>
>                 Key: GROOVY-7375
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7375
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.3
>            Reporter: Geoff Cadien
>            Priority: Major
>
> {code}
>  abstract class A {
>    private void m() {
>     println 'm'
>   }
>     
>   void wrong() {
>     m()
>     Closure c = {
>       m()
>     }
>     c()
>   }
> }
> class B {
>   A a = new A() {}
>   
>   void b() {
>    a.wrong()
>  }
> }
> def b = new B()
> b.b()
> {code}  
> Produces the following error:
> {code}
> groovy.lang.MissingMethodException: No signature of method: B.m() is applicable for argument types: () values: []
> Possible solutions: b(), is(java.lang.Object), dump(), any(), any(groovy.lang.Closure), use([Ljava.lang.Object;)
> 	at B.this$dist$invoke$1(wrong.groovy)
> 	at B$1.methodMissing(wrong.groovy)
> 	at A.invokeMethod(wrong.groovy)
> 	at A$_wrong_closure1.doCall(wrong.groovy:9)
> 	at A$_wrong_closure1.doCall(wrong.groovy)
> 	at A.wrong(wrong.groovy:12)
> 	at A$wrong.call(Unknown Source)
> 	at B.b(wrong.groovy:20)
> 	at B$b.call(Unknown Source)
> 	at wrong.run(wrong.groovy:25)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)