Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.8, 2.1.3
-
None
-
JDK1.7
Description
Can not access private static constant from colosure with @CompileStatic
Code:
@groovy.transform.CompileStatic class A{ private static final int BASE = 10 void test() { def c = { println BASE } c() } } new A().test()
Output(Without @CompileStatic)
10
Output(With @CompileStatic)
1 compilation error: Access to A#BASE is forbidden at line: -1, column: -1
But this code can work(wrap another closure)
@groovy.transform.CompileStatic class A{ private static final int BASE = 10 void test() { def c = { def c1 = { println BASE } c1() } c() } } new A().test()