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

Daniel Sun commented on GROOVY-7031:
------------------------------------

The last assert should be `assert s.str == 'test'`

> @CompileStatic breaks assign in combination with dereferencing
> --------------------------------------------------------------
>
>                 Key: GROOVY-7031
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7031
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.3.6, 2.4.0-rc-1
>         Environment: java version "1.8.0_11"
>            Reporter: Florian Freudenberg
>            Priority: Major
>         Attachments: CompileStaticAssignmentTest.groovy
>
>
> @CompileStatic breaks assignment for code like
> {code}
> @groovy.transform.CompileStatic
> class StaticClass {
>     StringHolder holder = new StringHolder()
>     String str
>     StaticClass(String s) {
>         str = holder.str = s
>     }
> }
> class StringHolder {
>     String str
> }
> def s = new StaticClass('test')
> assert s.holder.str == 'test'
> assert s.str != 'test'
> {code}
> The second assert fails because s.str == null. Without @CompileStatic it 
> works correctly (and as java).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to