[
https://issues.apache.org/jira/browse/GROOVY-9618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17160325#comment-17160325
]
Paul King edited comment on GROOVY-9618 at 7/22/20, 6:36 AM:
-------------------------------------------------------------
Proposed PR#1316 merged. Notes:
* Special handling is done for the upper and lowercase variants rather than
trying to represent both variants as meta bean properties, otherwise when
serialising or calling {{getProperties()}}, you get two copies of things.
* There is some special handling of an upper case "Class" field vs
{{getClass()}} (see GROOVY-1018) but other cases e.g. {{getMetaClass()}} aren't
covered. We might want to extend "Class" support to static imports/categories.
It is a breaking change in cases like "MetaClass" and "Properties" but you can
access the field using attribute notation in those cases. Lowercase properties
are unaffected.
* If you have a field with a name like {{Foo}} and an explicit getter
{{getFoo()}}, then the priority of access will now be different but you can use
the {{.@Foo}} notation to get directly to the field.
was (Author: paulk):
Proposed PR#1316 merged. Notes:
* Special handling is done for the upper and lowercase variants rather than
trying to represent both variants as meta bean properties, otherwise when
serialising or calling {{getProperties()}}, you get two copies of things.
* There is some special handling of an upper case "Class" field vs
{{getClass()}} (see GROOVY-1018) but other cases e.g. {{getMetaClass()}} aren't
covered. We might want to extend "Class" support to static imports/categories.
It is a breaking change in cases like "MetaClass" and "Properties" but you can
access the field using attribute notation in those cases. Lowercase properties
are unaffected.
> Property reference resolves to field, not getter when property name is single
> upper-case letter
> -----------------------------------------------------------------------------------------------
>
> Key: GROOVY-9618
> URL: https://issues.apache.org/jira/browse/GROOVY-9618
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.19, 3.0.4, 2.5.12
> Reporter: Eric Milles
> Assignee: Paul King
> Priority: Major
> Labels: breaking
> Fix For: 4.0.0-alpha-1, 3.0.5
>
> Time Spent: 2.5h
> Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> class A {
> private static X = 1
> static getX() { 2 }
> static class B {
> }
> }
> class C extends A.B {
> void test() {
> print X
> }
> }
> new C().test()
> {code}
> Execution of this script prints "1" when "2" is expected. If static property
> name is changed to "XY" or "x" the resolution works as expected.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)