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

Eric Milles commented on GROOVY-11875:
--------------------------------------

Here is the source of the cast: 
https://github.com/apache/groovy/blob/8ecc02ed558fc04d802b632e9af2c50895b3fb91/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java#L1465

> Inner classes property vs field access
> --------------------------------------
>
>                 Key: GROOVY-11875
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11875
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 5.0.4
>            Reporter: Gregory Moltchadski
>            Assignee: Eric Milles
>            Priority: Major
>         Attachments: MRE.groovy
>
>
> The attached valid piece of code works fine on Groovy 4, but fails on Groovy 
> 5 with the following exception:
> Cannot cast object 'false' with class 'java.lang.Boolean' to class 
> 'java.util.concurrent.atomic.AtomicBoolean'
> It looks like the inner class tries to access the property via the underlying 
> field instead of the getter.
> {code:groovy}
> import java.util.concurrent.atomic.AtomicBoolean
> class Test
> {
>   private AtomicBoolean test = new AtomicBoolean()
>   boolean isTest() { test.get() }
>   void bar() { new Inner().bar() }
>   class Inner
>   {
>     void bar() { println test }
>   }
> }
> Test test = new Test()
> test.bar()
> {code}



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

Reply via email to