[ https://issues.apache.org/jira/browse/GROOVY-9043?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16831664#comment-16831664 ]
Eric Milles edited comment on GROOVY-9043 at 5/2/19 2:48 PM: ------------------------------------------------------------- Added the CompileStatic annotations; sorry for missing that the first time around. I'll retest the second case. I thought I had it running successfully. Here is my test case that runs to completion and gets expected output: {code:java} @Test public void testCompileStatic9043_peerToPackage2() { //@formatter:off String[] sources = { "p/Main.groovy", "package p\n" + "import groovy.transform.*\n" + "class Main {\n" + " @PackageScope static final String VALUE = 'value'\n" + " static main(args) {\n" + " new Peer().meth()\n" + " }\n" + "}\n", "q/More.groovy", "package q\n" + "class More extends p.Main {}\n", "p/Peer.groovy", "package p\n" + "import groovy.transform.*\n" + "@CompileStatic class Peer {\n" + " void meth() {\n" + " print q.More.VALUE\n" + " }\n" + "}\n", }; //@formatter:on runConformTest(sources, "value"); } {code} was (Author: emilles): Added the CompileStatic annotations; sorry for missing that the first time around. I'll retest the second case. I thought I had it running successfully. > Access to package-scoped static field is forbidden for inner class in static > compilation mode > --------------------------------------------------------------------------------------------- > > Key: GROOVY-9043 > URL: https://issues.apache.org/jira/browse/GROOVY-9043 > Project: Groovy > Issue Type: Bug > Affects Versions: 3.0.0-alpha-4, 2.5.6 > Reporter: Basil Peace > Assignee: Paul King > Priority: Minor > Fix For: 3.0.0-beta-1, 2.5.7 > > > Given: > > {code:java} > import groovy.transform.CompileStatic > import groovy.transform.PackageScope > @CompileStatic > class Test { > @PackageScope > static final String S = 'Some constant' > static class Inner { > String method() { > S > } > } > } > {code} > there is a compilation error: > > > {noformat} > Access to Test#S is forbidden @ line -1, column -1.{noformat} > No error without @CompileStatic. > > Analogous code works in Java -- This message was sent by Atlassian JIRA (v7.6.3#76005)