You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2017/05/02 02:04:17 UTC
[jira] [Closed] (GROOVY-6052) ++ or -- doesn't respect final
modifier
[ https://issues.apache.org/jira/browse/GROOVY-6052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-6052.
-----------------------------
> ++ or -- doesn't respect final modifier
> ---------------------------------------
>
> Key: GROOVY-6052
> URL: https://issues.apache.org/jira/browse/GROOVY-6052
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 1.8.8, 2.0.6, 2.1.1
> Reporter: Dinko Srkoc
> Fix For: 2.5.0-alpha-1
>
>
> Groovy respects {{final}} modifier for fields and method parameters, but using {{++}} or {{--}} is still allowed:
> {code}
> class A {
> final foo = 42
> def incrementField() { ++foo }
> def incrementParam(final a) { ++a }
> }
> def a = new A()
> assert a.incrementField() == 43
> assert a.incrementParam(1) == 2
> {code}
> However, {{a.foo++}} throws {{ReadOnlyPropertyException}}.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)