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

Eric Milles edited comment on GROOVY-11633 at 4/22/25 5:54 PM:
---------------------------------------------------------------

STC and the runtime determine read-only for a property by 1) lack of a setter 
and 2) final field (if property involves a field).  When I was fixing 
GROOVY-11512 I noticed that the modifiers in 0x1F were being transferred to the 
getter, isser and setter.  I switched to using 
[{{adjustPropertyModifiersForMethod}}|https://github.com/apache/groovy/blob/d77d909df28896a21fe4958a201f98c891d5cb51/src/main/java/org/codehaus/groovy/ast/tools/PropertyNodeUtils.java#L39]
 for a consistent outcome between `Verifier` and `TraitASTTransformation`.  See 
GROOVY-3726


was (Author: emilles):
STC and the runtime determine read-only for a property by 1) lack of a setter 
and 2) final field (if property involves a field).  When I was fixing 
GROOVY-11512 I noticed that the modifiers in 0x1F were being transferred to the 
getter, isser and setter.  I switched to using 
[`adjustPropertyModifiersForMethod`|https://github.com/apache/groovy/blob/d77d909df28896a21fe4958a201f98c891d5cb51/src/main/java/org/codehaus/groovy/ast/tools/PropertyNodeUtils.java#L39]
 for a consistent outcome between `Verifier` and `TraitASTTransformation`.  See 
GROOVY-3726

> 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