Repository: groovy
Updated Branches:
  refs/heads/master 0958592c4 -> 011b98e13


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

Branch: refs/heads/master
Commit: 011b98e133048e417f330fb83a5c56294472e8cc
Parents: 0958592
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:18:39 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/011b98e1/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/011b98e1/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