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

Eric Milles closed GROOVY-8265.
-------------------------------
    Resolution: Fixed

> If CompileStatic is used, metaClass variable shadowing triggers exception 
> when invoking closures
> ------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8265
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8265
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime, Static compilation
>    Affects Versions: 2.4.12
>            Reporter: Sergio Nalin
>            Priority: Minor
>         Attachments: Bug.groovy
>
>
> See the small attached example class.
> Problem arises if you define a local variable and name it "metaClass", then 
> call a closure that accepts some parameters like map.each { key, value -> ... 
> }.
> When the code gets to Closure.call(Object... args) it executes:
> return (V) getMetaClass().invokeMethod(this,"doCall",args);
> only now getMetaClass() returns the shadowed metaClass variable, not the 
> Closure's metaClass and an exception is thrown if the class that the external 
> metaClass belongs to does not define a doCall(args) method.
> This seems to be happening only with @CompileStatic
> Renaming the local variable from metaClass to anything else works around the 
> problem.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to