diff options
author | Stephan Herrmann | 2012-05-29 14:24:31 +0000 |
---|---|---|
committer | Ayushman Jain | 2012-05-29 14:24:31 +0000 |
commit | ee3dfd8d808b314a45a2da4f8014d314b68011f8 (patch) | |
tree | 3e2103adfaaf128648c0f1b2e359a747cc7dfeaa | |
parent | ed6be0a94093e63f3ba13a0769b90a8ca2a5b2b0 (diff) | |
download | eclipse.jdt.core-ee3dfd8d808b314a45a2da4f8014d314b68011f8.tar.gz eclipse.jdt.core-ee3dfd8d808b314a45a2da4f8014d314b68011f8.tar.xz eclipse.jdt.core-ee3dfd8d808b314a45a2da4f8014d314b68011f8.zip |
Fixed bug 380750: [compiler] local incorrectly flagged as uninitializedv20120529-1424
due to fix for bug 359495
3 files changed, 28 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java index b5dc25378f..56b2ce30f5 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java @@ -2579,6 +2579,29 @@ public void testBug380313b() { }, ""); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=380750 +// verify that s0 is not reported as uninitialized +public void testBug380750() { + if (this.complianceLevel < ClassFileConstants.JDK1_5) + return; + this.runConformTest( + new String[] { + "X.java", + "public class X {\n" + + " void foo(String[] args) {\n" + + " String s0;\n" + + " for(String s : singleton(s0=\"\")) {\n" + + " System.out.println(s);\n" + + " }\n" + + " System.out.println(s0);\n" + + " }\n" + + " String[] singleton(String s) {\n" + + " return new String[] {s};\n" + + " }\n" + + "}\n" + }, + ""); +} public static Class testClass() { return FlowAnalysisTest.class; } diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html index 88424f283c..4fcd104c14 100644 --- a/org.eclipse.jdt.core/buildnotes_jdt-core.html +++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html @@ -52,7 +52,9 @@ Eclipse SDK 3.8.0 - %date% - 3.8.0 <h2>What's new in this drop</h2> <h3>Problem Reports Fixed</h3> -<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380313">380313</a> +<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380750">380750</a> +[compiler] local incorrectly flagged as uninitialized due to fix for bug 359495 +<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=380313">380313</a> Inconsistent stack error when using Java 1.7 <a name="v_C56"></a> diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java index 85ee809d7b..4456f6eff6 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java @@ -121,7 +121,7 @@ public class ForeachStatement extends Statement { // code generation can be optimized when no need to continue in the loop exitBranch = flowInfo.unconditionalCopy(). - addNullInfoFrom(condInfo.initsWhenFalse()); + addInitializationsFrom(condInfo.initsWhenFalse()); // TODO (maxime) no need to test when false: can optimize (same for action being unreachable above) if ((actionInfo.tagBits & loopingContext.initsOnContinue.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) { @@ -169,6 +169,7 @@ public class ForeachStatement extends Statement { exitBranch, false, true /*for(;;){}while(true); unreachable(); */); + mergedInfo.resetAssignmentInfo(this.elementVariable.binding); this.mergedInitStateIndex = currentScope.methodScope().recordInitializationStates(mergedInfo); return mergedInfo; } |