You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2024/02/25 17:16:00 UTC

[jira] [Assigned] (GROOVY-11319) Access to a private property of a parent object is not caught

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

Eric Milles reassigned GROOVY-11319:
------------------------------------

    Assignee: Eric Milles

> Access to a private property of a parent object is not caught
> -------------------------------------------------------------
>
>                 Key: GROOVY-11319
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11319
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Minor
>
> I have the following ill-typed program
> {code}
> class A {
>   private int getX() {
>     return 1;
>   }
> }
> class B extends A {
>   void test() {
>     def y = super.x;
>     System.out.println(y);
>   }
> }
> public class Test {
>     public static void main(String[] args) {
>       new B().test();
>     }
> }
> {code}
> h3. Actual behavior
> The program compiles. When I run it, I receive:
> {code}
> Exception in thread "main" groovy.lang.MissingPropertyException: No such property: x for class: B
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:68)
>         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getPropertyOnSuper(ScriptBytecodeAdapter.java:426)
>         at B.test(test.groovy:9)
>         at Test.main(test.groovy:16)
> {code}
> h3. Expected behavior
> The problem is on line 9, when the program accesses the private property x of the parent object.
> Tested against master (commit: e17149013c5943ad3493f9597e6720eb6529d120)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)