Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
index 498a81408c..88948bb859 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
* Stephan Herrmann - Contributions for
* bug 319201 - [null] no warning when unboxing SingleNameReference causes NPE
* bug 349326 - [1.7] new warning for missing try-with-resources
+ * bug 345305 - [compiler][null] Compiler misidentifies a case of "variable can only be null"
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -93,7 +94,7 @@ public class ForStatement extends Statement {
this.scope,
(condLoopContext =
new LoopingFlowContext(flowContext, flowInfo, this, null,
- null, this.scope)),
+ null, this.scope, true)),
condInfo);
if ((this.condition.implicitConversion & TypeIds.UNBOXING) != 0) {
this.condition.checkNPE(currentScope, flowContext, flowInfo);
@@ -121,13 +122,15 @@ public class ForStatement extends Statement {
actionInfo = condInfo.initsWhenTrue().unconditionalCopy();
loopingContext =
new LoopingFlowContext(flowContext, flowInfo, this,
- this.breakLabel, this.continueLabel, this.scope);
+ this.breakLabel, this.continueLabel, this.scope, false);
+ // there is no action guarded by a preTest, so we use preTest=false
+ // to avoid pointless burdens of updating FlowContext.conditionalLevel
}
}
else {
loopingContext =
new LoopingFlowContext(flowContext, flowInfo, this, this.breakLabel,
- this.continueLabel, this.scope);
+ this.continueLabel, this.scope, true);
FlowInfo initsWhenTrue = condInfo.initsWhenTrue();
this.condIfTrueInitStateIndex =
currentScope.methodScope().recordInitializationStates(initsWhenTrue);
@@ -168,7 +171,7 @@ public class ForStatement extends Statement {
if (this.increments != null) {
incrementContext =
new LoopingFlowContext(flowContext, flowInfo, this, null,
- null, this.scope);
+ null, this.scope, true);
FlowInfo incrementInfo = actionInfo;
this.preIncrementsInitStateIndex =
currentScope.methodScope().recordInitializationStates(incrementInfo);

Back to the top