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

Eric Milles updated GROOVY-9609:
--------------------------------
    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.

{code:groovy}
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]
{code}

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

  was:
{{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.

{code:groovy}
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]
{code}

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.


> ScriptBytecodeAdapter.getPropertyOnSuper fails with method missing for 
> getProperty
> ----------------------------------------------------------------------------------
>
>                 Key: GROOVY-9609
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9609
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Priority: Major
>
> {{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.
> {code:groovy}
> 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]
> {code}
> 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



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to