Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 1319e646d -> 6e3e62c6a
refine fix for GROOVY-8386/GROOVY-8094: remove an edge case that wasn't meant to trigger error Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6e3e62c6 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6e3e62c6 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6e3e62c6 Branch: refs/heads/GROOVY_2_6_X Commit: 6e3e62c6aa203109a46a10529052afdb49bde7df Parents: 1319e64 Author: paulk <pa...@asert.com.au> Authored: Tue Feb 13 17:18:39 2018 +1000 Committer: paulk <pa...@asert.com.au> Committed: Tue Feb 13 17:20:46 2018 +1000 ---------------------------------------------------------------------- src/main/java/org/codehaus/groovy/classgen/Verifier.java | 3 ++- .../codehaus/groovy/classgen/FinalVariableAnalyzerTest.groovy | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/6e3e62c6/src/main/java/org/codehaus/groovy/classgen/Verifier.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/codehaus/groovy/classgen/Verifier.java b/src/main/java/org/codehaus/groovy/classgen/Verifier.java index 59a8d60..aad5940 100644 --- a/src/main/java/org/codehaus/groovy/classgen/Verifier.java +++ b/src/main/java/org/codehaus/groovy/classgen/Verifier.java @@ -274,7 +274,8 @@ public class Verifier implements GroovyClassVisitor, Opcodes { @Override public void variableNotAlwaysInitialized(final VariableExpression var) { - throw new RuntimeParserException("The variable [" + var.getName() + "] may be uninitialized", var); + if (Modifier.isFinal(var.getAccessedVariable().getModifiers())) + throw new RuntimeParserException("The variable [" + var.getName() + "] may be uninitialized", var); } }; } http://git-wip-us.apache.org/repos/asf/groovy/blob/6e3e62c6/src/test/org/codehaus/groovy/classgen/FinalVariableAnalyzerTest.groovy ---------------------------------------------------------------------- diff --git a/src/test/org/codehaus/groovy/classgen/FinalVariableAnalyzerTest.groovy b/src/test/org/codehaus/groovy/classgen/FinalVariableAnalyzerTest.groovy index 44a3a2f..b211ee4 100644 --- a/src/test/org/codehaus/groovy/classgen/FinalVariableAnalyzerTest.groovy +++ b/src/test/org/codehaus/groovy/classgen/FinalVariableAnalyzerTest.groovy @@ -246,13 +246,13 @@ class FinalVariableAnalyzerTest extends GroovyTestCase { ''' } - void testPrePostfixShouldNotCompileWithUninitializedVar() { + void testPrePostfixShouldNotCompileWithUninitializedFinalVar() { assertFinalCompilationErrors(['x'], ''' - def x + final x x++ ''', true) assertFinalCompilationErrors(['y'], ''' - def y + final y --y ''', true) }