[ 
https://issues.apache.org/jira/browse/GROOVY-11675?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King updated GROOVY-11675:
-------------------------------
    Description: 
Split property definitions were created as an alternative to the full long-hand 
way to express a property. They all modifiers (final and synchronized), and 
annotations to be applied to either the backing field or the accessors.
 
{code:groovy}
import groovy.transform.PackageScope

class MyTask {
    @Deprecated private final Integer f1 = 0
    final Integer f1

    protected synchronized Integer f2 = 0
    synchronized Integer f2

    public Integer f3 = 0
    @Deprecated Integer f3
}

println MyTask
{code}
Currently, everything is carried across except for the final on the {{f1}} 
accessor methods.

  was:
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.




> split property definitions aren't carrying final modifier to getters
> --------------------------------------------------------------------
>
>                 Key: GROOVY-11675
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11675
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.24, 4.0.25, 4.0.26
>            Reporter: Paul King
>            Priority: Major
>
> Split property definitions were created as an alternative to the full 
> long-hand way to express a property. They all modifiers (final and 
> synchronized), and annotations to be applied to either the backing field or 
> the accessors.
>  
> {code:groovy}
> import groovy.transform.PackageScope
> class MyTask {
>     @Deprecated private final Integer f1 = 0
>     final Integer f1
>     protected synchronized Integer f2 = 0
>     synchronized Integer f2
>     public Integer f3 = 0
>     @Deprecated Integer f3
> }
> println MyTask
> {code}
> Currently, everything is carried across except for the final on the {{f1}} 
> accessor methods.



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

Reply via email to