[ https://issues.apache.org/jira/browse/GROOVY-11319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17820494#comment-17820494 ]
Eric Milles commented on GROOVY-11319: -------------------------------------- Groovy 3 does error for "super.x". The restriction may have been lifted for 4+ -- there have been some improvements in private member access. > 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 > 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)