You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/07/23 14:17:06 UTC

[jira] [Closed] (GROOVY-9608) MetaClassImpl.getAttribute(Class,Object,String,boolean) drops super

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

Paul King closed GROOVY-9608.
-----------------------------

> MetaClassImpl.getAttribute(Class,Object,String,boolean) drops super
> -------------------------------------------------------------------
>
>                 Key: GROOVY-9608
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9608
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.19, 3.0.4, 2.5.12
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 2.4.20, 3.0.5, 2.5.13
>
>
> {{ScriptBytecodeAdapter.getFieldOnSuper}} calls {{MetaClass#getAttribute(SuperType,thisObject,"fieldName",true)}}.   
>  {{MetaClassImpl}} delegates and drops the super flag in the process.
> {code:groovy}
> class A {
>   public x = 'A'
> }
> class B extends A {
>   public x = 'B'
> }
> def a = new A()
> println a.metaClass.getAttribute(A, a, 'x', false) // prints "A"
> def b = new B()
> println b.metaClass.getAttribute(B, b, 'x', false) // prints "B"
> println b.metaClass.getAttribute(A, b, 'x', true) // prints "B", but "A" is expected
> println ScriptBytecodeAdapter.getFieldOnSuper(A, b, 'x') // prints "B", but "A" is expected
> {code}



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