Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 4318a0a7b -> ef4a7985d


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/ef4a7985
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ef4a7985
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ef4a7985

Branch: refs/heads/GROOVY_2_5_X
Commit: ef4a7985d6cb4333dc78d2f02ab9822098a28640
Parents: 4318a0a
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:21:05 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/ef4a7985/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/ef4a7985/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)
     }

Reply via email to