Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
I have the following ill-typed program
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(); } }
Actual behavior
The program compiles. When I run it, I receive:
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)
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)
Attachments
Issue Links
- is related to
-
GROOVY-6097 Using super.propertyName gives a MissingMethodException when the property is a boolean and uses the "isPropertyName" naming convention.
- Closed
-
GROOVY-8999 Access to private fields and methods from subclass exhibits strange behavior
- Closed
-
GROOVY-9851 Private field and method use from subclass is inconsistent
- Closed
- relates to
-
GROOVY-11223 STC: error message for inaccessible setter is not too helpful
- Closed
-
GROOVY-11356 STC: missing property error for implicit-this reference to private super field or method
- Closed