View | Details | Raw Unified | Return to bug 336428 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 524-532 Link Here
524
				if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
524
				if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
525
					recordNullReference(local, reference, checkType);
525
					recordNullReference(local, reference, checkType);
526
				}
526
				}
527
			} else if (! flowInfo.cannotBeDefinitelyNullOrNonNull(local)) {
527
			} else if (flowInfo.cannotBeDefinitelyNullOrNonNull(local)) {
528
				return; // no reason to complain
529
			} else {
528
				if (flowInfo.isPotentiallyNonNull(local)) {
530
				if (flowInfo.isPotentiallyNonNull(local)) {
529
					recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK);
531
					recordNullReference(local, reference, CAN_ONLY_NON_NULL | checkType & CONTEXT_MASK);
532
				} else if (flowInfo.isPotentiallyNull(local)) {
533
					recordNullReference(local, reference, CAN_ONLY_NULL | checkType & CONTEXT_MASK);
530
				} else {
534
				} else {
531
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
535
					if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) {
532
						recordNullReference(local, reference, checkType);
536
						recordNullReference(local, reference, checkType);
(-)src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java (+17 lines)
Lines 13832-13835 Link Here
13832
			"}"},
13832
			"}"},
13833
		"");
13833
		"");
13834
}
13834
}
13835
// Bug 336428 - [compiler][null] bogus warning "redundant null check" in condition of do {} while() loop
13836
public void testBug336428() {
13837
	this.runConformTest(
13838
		new String[] {
13839
	"DoWhileBug.java",
13840
			"public class DoWhileBug {\n" + 
13841
			"	void test(boolean b1, Object o1) {\n" + 
13842
			"		Object o2 = new Object();\n" + 
13843
			"		do {\n" +
13844
			"           if (b1)\n" + 
13845
			"				o1 = null;\n" + 
13846
			"		} while ((o2 = o1) != null);\n" + 
13847
			"	}\n" + 
13848
			"}"	
13849
		},
13850
		"");
13851
}
13835
}
13852
}

Return to bug 336428