Hi Jochen,
did you ever get around to pushing the fix you mentioned ?
I just checked if the current GROOVY_2_4_X snapshot works for Minecraft
modding, but alas it still throws:
https://issues.apache.org/jira/browse/GROOVY-8385?focusedCommentId=16284807&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-16284807
Cheers,
mg
On 24.11.2017 01:46, Jochen Theodorou wrote:
Hi all,
the test is defined as this:
void testUseGetterFieldAccess() {
assertScript '''
class A {
boolean getterCalled = false
protected int x
public int getX() {
getterCalled = true
x
}
}
class B extends A {
void usingGetter() {
this.x
}
}
B b = new B()
b.usingGetter()
assert b.isGetterCalled() == true
'''
assert astTrees['B'][1].contains('INVOKEVIRTUAL B.getX')
}
The test was written as a reaction to GROOVY-5619, which is to ensure
that we do not call a setter in this case... only there is no setter
here. Instead this test fixates the behaviour of the static compiler
to call a getter instead of directly accessing the field. Direct
access to the field is what is required for GROOVY-8385
In my opinion the test is wrong, but I'd like to hear others about this.
And another point. We seem to have no similar test for dynamic Groovy.
Groovy does use direct field access if the field is available on
"this". But the question here is if that extends to all super classes.
In my opinion it should.
If I get no vetos I will push a fix for this for all current groovy
versions
bye Jochen