Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
ScriptBytecodeAdapter.getPropertyOnSuper calls invokeSuperMethodN(SuperType,thisObject,"getProperty", new Object[]{"propertyName"}), which calls thisObject.getMetaClass().invokeMethod(SuperType,thisObject,"getProperty", messageArguments, true, true). MetaClassImpl's invokeMethod is failing to find public getProperty(String) method in class A.
class A { def getX() { 'A' } } class B extends A { def getX() { 'B' } } println new A().getProperty("x") // prints "A" println new B().getProperty("x") // prints "B" println ScriptBytecodeAdapter.getPropertyOnSuper(A, new B(), "x") // MissingMethodException: No signature of method: B.getProperty() is applicable for argument types: (String) values: [x]
Also, the message indicates that B is the type that was searched; it should display A.
I found a similar result for ScriptBytecodeAdapter.getFieldOnSuper in GROOVY-9608. I think there is something wrong with the cached super information in MetaClassImpl. https://github.com/apache/groovy/blob/0b886e910bbb0e75aae527fae2cab0ec4f096bf2/src/test/groovy/bugs/Groovy9608.groovy#L53