Saravanan created GROOVY-11612: ---------------------------------- Summary: Groovy incorrectly compiles the accessing of InnerClass's variables when the OuterClass has a getter for it Key: GROOVY-11612 URL: https://issues.apache.org/jira/browse/GROOVY-11612 Project: Groovy Issue Type: Bug Components: Compiler, Static compilation Affects Versions: 4.0.24 Reporter: Saravanan
{code:java} public class Outer { public String description; public Outer(Inner inner) { // Groovy will compile this but the statement looks like this and will create a runtime error // String var3 = ((Outer)ScriptBytecodeAdapter.castToType(inner, Outer.class)).getDescription(); this.description = inner.description; } public String getDescription() { return description; } public static Inner inner() { return new Inner(); } public static class Inner { public String description = "test"; public Inner() { } } } {code} The compile in With @CompileStatic will pass but the generated code will fail at runtime -- This message was sent by Atlassian Jira (v8.20.10#820010)