[ 
https://issues.apache.org/jira/browse/GROOVY-11612?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-11612:
---------------------------------
    Description: 
{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

  was:
{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


> 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.24
>            Reporter: Saravanan
>            Assignee: Eric Milles
>            Priority: Minor
>
> {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)

Reply via email to