[
https://issues.apache.org/jira/browse/GROOVY-5450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-5450:
--------------------------------
Fix Version/s: 3.0.18
> Final field assignment check on static compilation
> --------------------------------------------------
>
> Key: GROOVY-5450
> URL: https://issues.apache.org/jira/browse/GROOVY-5450
> Project: Groovy
> Issue Type: New Feature
> Components: Compiler
> Affects Versions: 2.0-beta-3
> Reporter: Renato Garcia
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-2, 3.0.18
>
>
> The following class definition should generate a compilation error on final
> field assignment.
> {code}
> @groovy.transform.CompileStatic
> class StaticGroovy3 {
> def testFinalField() {
> def ff = new FinalField()
> ff.aField = 'y'
> println ff
> }
> }
> class FinalField {
> final aField = 'x'
> }
> new StaticGroovy3().testFinalField()
> {code}
> Fails at runtime with {{groovy.lang.ReadOnlyPropertyException: Cannot set
> readonly property: aField for class: FinalField}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)