[
https://issues.apache.org/jira/browse/GROOVY-9608?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17453699#comment-17453699
]
Eric Milles commented on GROOVY-9608:
-------------------------------------
Fix for non-private super fields:
https://github.com/apache/groovy/commit/1ac400f856b53f4514fe820498103c72277a2c5d
> 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.20.1#820001)