Description
The following code runs on groovy 2.4.18 but not on groovy 3.0.1.
static void main(String[] args) { final String result switch (2) { case 1: result = "a"; break; case 2: result = "b"; break; default: result = "x" } println result }
Error: Groovyc: The variable [result] is declared final but is reassigned.
Since we use final in our codebase a lot (although it seems to be ignored by groovy 2.4),
we will have to adjust a lot of places to make our code groovy 3.0 compatible.
Attachments
Issue Links
- is cloned by
-
GROOVY-9438 Incorrect handling of particular case statements within switch
- Closed
- links to