[
https://issues.apache.org/jira/browse/GROOVY-11875?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-11875.
------------------------------
> 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
> Fix For: 5.0.5
>
> 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)