You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Saravanan (Jira)" <ji...@apache.org> on 2025/04/20 15:04:00 UTC
[jira] [Commented] (GROOVY-11612) Groovy incorrectly compiles the accessing of InnerClass's variables when the OuterClass has a getter for it
[ https://issues.apache.org/jira/browse/GROOVY-11612?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945971#comment-17945971 ]
Saravanan commented on GROOVY-11612:
------------------------------------
Can this be ported up to 5.0.0.13?
> 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: Static compilation
> Affects Versions: 4.0.21
> Reporter: Saravanan
> Assignee: Eric Milles
> Priority: Minor
> Fix For: 4.0.22
>
>
> {code:java}
> @groovy.transform.CompileStatic
> 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
> }
> static Inner inner() {
> return new Inner()
> }
> static class Inner {
> public String description = "test"
> }
> }
> {code}
> Compiles successfully but the generated code fails at runtime
--
This message was sent by Atlassian Jira
(v8.20.10#820010)