Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.4
-
None
-
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (Zulu 8.44.0.11-CA-macosx) (build 1.8.0_242-b20)
OpenJDK 64-Bit Server VM (Zulu 8.44.0.11-CA-macosx) (build 25.242-b20, mixed mode)
Description
When trying to access the property of a outer class from a static inner class the code should fail to compile.
It doesn't fail to compile when the access happens from inside a @DelegatesTo Closure.
import groovy.transform.CompileStatic @CompileStatic class Delegate { static void delegate(@DelegatesTo(Delegate) Closure c) { c.delegate = new Delegate() c() } } @CompileStatic class Outer { String propertyName static class Inner { void someFunction() { // Moving this here results in a compilation error // println(propertyName) Delegate.delegate { // This causes a GroovyCastException at runtime because the generated code tries to access propertyName as if this were a instance of Outer? println(propertyName) } } } } new Outer.Inner().someFunction()
Attachments
Issue Links
- breaks
-
GROOVY-9825 interface constants from super interfaces lost in some contexts
- Closed