[ https://issues.apache.org/jira/browse/GROOVY-11198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17776743#comment-17776743 ]
Eric Milles edited comment on GROOVY-11198 at 10/18/23 3:43 PM: ---------------------------------------------------------------- There may be an initialization order issue here as well. Enum constants and fields are not initialized in declaration order (see GROOVY-3963, GROOVY-6498, GROOVY-7025, GROOVY-10721). Sorry, just noticed that in your case, the constant comes from the outer class. was (Author: emilles): There may be an initialization order issue here as well. Enum constants and fields are not initialized in declaration order (see GROOVY-3963, GROOVY-6498, GROOVY-7025, GROOVY-10721). > access to public static variable forbidden in enum > -------------------------------------------------- > > Key: GROOVY-11198 > URL: https://issues.apache.org/jira/browse/GROOVY-11198 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 5.0.0-alpha-1, 5.0.0-alpha-2 > Reporter: Jason Garrett > Priority: Minor > > With static compilation, accessing a public static class variable within an > enum causes a compilation error. > {code:java} > import groovy.transform.CompileStatic > @CompileStatic // compiles without this > class PublicStaticInEnum { > public static double FOO = 0.0d // compiles without "public" > enum MyEnum { > FOO_VAL(FOO) // Access to example.PublicStaticInEnum$MyEnum#FOO is > forbidden > double myDouble > MyEnum(double myDouble) { > this.myDouble = myDouble > } > } > } {code} > This example fails to compile with: Access to > example.PublicStaticInEnum$MyEnum#FOO is forbidden -- This message was sent by Atlassian Jira (v8.20.10#820010)