[ 
https://issues.apache.org/jira/browse/GROOVY-11633?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17946398#comment-17946398
 ] 

Paul King commented on GROOVY-11633:
------------------------------------

It is best not to conflate property access in general with modifier issues. The 
direct access of the field inside the class is well known and well defined. See 
the "It is worth noting" paragraph in:
https://groovy-lang.org/objectorientation.html#_fields_and_properties

The modifiers for the getter is a valid discussion point. Given that properties 
are a Groovy thing (albeit related to JavaBeans), it is up to us to define the 
semantics in all cases. Looking at the previous link, we don't do that for this 
particular case. Properties with the final modifier have always been referred 
to as read-only properties. We state that the field will be final but don't 
give a definitive answer for the getter.

Obviously, you can go the long-hand path of explicitly defining the getter, but 
I would have hoped that at least with split definitions, we could have 
supported the two cases of final/non-final getters. But it doesn't seem to work 
either. I think we could tidy this up.

> final fields no longer produce final getters
> --------------------------------------------
>
>                 Key: GROOVY-11633
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11633
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.24, 4.0.25, 4.0.26
>            Reporter: Octavia Togami
>            Assignee: Eric Milles
>            Priority: Major
>         Attachments: FinalProp.groovy
>
>
> In Groovy 3 and versions of Groovy 4 at or before 4.0.23, a `final` field 
> would also produce a `final` getter. Due to changes made in 
> https://github.com/apache/groovy/commit/88c6336021f71d702da5292aeaac9e9859aeab1a
>  (discovered via `git bisect`), 4.0.24 and onwards now produce a non-`final` 
> getter, which allows overriding of the method. A reproducer which should fail 
> to compile if the issue is fixed is attached.
> This has a minor affect on Gradle's upgrade to Groovy 4, where some 
> properties won't properly attach to their owning object and produce worse 
> error messages.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to