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

Eric Milles updated GROOVY-11319:
---------------------------------
    Fix Version/s: 4.0.21

> 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
>             Fix For: 5.0.0-alpha-8, 4.0.21
>
>
> 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)

Reply via email to