You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/05/04 18:30:00 UTC

[jira] [Resolved] (GROOVY-11044) SC: property access within closure produces cast exception

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

Eric Milles resolved GROOVY-11044.
----------------------------------
    Resolution: Fixed

https://github.com/apache/groovy/commit/6177f7cf55b0eaec573e39624d8549ae5c68da55

> SC: property access within closure produces cast exception
> ----------------------------------------------------------
>
>                 Key: GROOVY-11044
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11044
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 4.0.12
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class Bar {
>   @groovy.beans.Bindable
>   String baz
>   String other
> }
> class Foo {
>   Bar bar
>   @groovy.beans.Bindable
>   String foo
>   @groovy.transform.CompileStatic
>   void postConstruct() {
>     bar = new Bar()
>     bar.with {
>       addPropertyChangeListener('baz') { event ->
>         other = 'value' // ClassCastException: class Foo cannot be cast to class Bar
>         print 'changed'
>       }
>     }
>     print 'ready;'
>   }
> }
> Foo foo = new Foo()
> foo.postConstruct()
> foo.getBar().setBaz('xxx')
> {code}



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