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

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullAnnotationTest.java (-1 / +31 lines)
Lines 52-58 Link Here
52
// Static initializer to specify tests subset using TESTS_* static variables
52
// Static initializer to specify tests subset using TESTS_* static variables
53
// All specified tests which do not belong to the class are skipped...
53
// All specified tests which do not belong to the class are skipped...
54
static {
54
static {
55
//		TESTS_NAMES = new String[] { "test_illegal_annotation_007" };
55
//		TESTS_NAMES = new String[] { "test_assignment_expression_1" };
56
//		TESTS_NUMBERS = new int[] { 561 };
56
//		TESTS_NUMBERS = new int[] { 561 };
57
//		TESTS_RANGE = new int[] { 1, 2049 };
57
//		TESTS_RANGE = new int[] { 1, 2049 };
58
}
58
}
Lines 2474-2479 Link Here
2474
		"Type mismatch: required \'@NonNull String\' but the provided value can be null\n" +
2474
		"Type mismatch: required \'@NonNull String\' but the provided value can be null\n" +
2475
		"----------\n");
2475
		"----------\n");
2476
}
2476
}
2477
public void test_assignment_expression_1() {
2478
	Map customOptions = getCompilerOptions();
2479
//	customOptions.put(CompilerOptions.OPTION_ReportPotentialNullSpecViolation, JavaCore.ERROR);
2480
	customOptions.put(JavaCore.COMPILER_NONNULL_IS_DEFAULT, JavaCore.ENABLED);
2481
	customOptions.put(JavaCore.COMPILER_PB_REDUNDANT_NULL_CHECK, JavaCore.ERROR);
2482
	runConformTestWithLibs(
2483
		new String[] {
2484
			"X.java",
2485
			"import org.eclipse.jdt.annotation.*;\n" +
2486
			"public class X {\n" +
2487
			"	@Nullable Object foo() {\n" +
2488
			"		Object o = null;\n" +
2489
			"		boolean keepLooking = true;\n" +
2490
			"		while(keepLooking) {\n" +
2491
			"			if ((o=getO()) != null) {\n" +
2492
			"				return o;\n" +
2493
			"			}\n" +
2494
			"		}\n" +
2495
			"		return null;\n" +
2496
			"	}\n" +
2497
			"\n" +
2498
			"	private @Nullable Object getO() {\n" +
2499
			"		return new Object();\n" +
2500
			"	}\n" +
2501
			"}\n",
2502
2503
		},
2504
		customOptions,
2505
		"");	
2506
}
2477
// a nonnull variable is dereferenced method of a nested type
2507
// a nonnull variable is dereferenced method of a nested type
2478
public void test_nesting_1() {
2508
public void test_nesting_1() {
2479
	Map customOptions = getCompilerOptions();
2509
	Map customOptions = getCompilerOptions();
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-2 / +2 lines)
Lines 119-125 Link Here
119
}
119
}
120
public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) {
120
public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) {
121
	super.checkNPE(scope, flowContext, flowInfo);
121
	super.checkNPE(scope, flowContext, flowInfo);
122
	if (nullStatus(flowInfo) == FlowInfo.POTENTIALLY_NULL)
122
	if ((nullStatus(flowInfo) & FlowInfo.POTENTIALLY_NULL) != 0)
123
		scope.problemReporter().messageSendPotentialNullReference(this.binding, this);
123
		scope.problemReporter().messageSendPotentialNullReference(this.binding, this);
124
}
124
}
125
/**
125
/**
Lines 281-287 Link Here
281
		if ((tagBits & TagBits.AnnotationNonNull) != 0)
281
		if ((tagBits & TagBits.AnnotationNonNull) != 0)
282
			return FlowInfo.NON_NULL;
282
			return FlowInfo.NON_NULL;
283
		if ((tagBits & TagBits.AnnotationNullable) != 0)
283
		if ((tagBits & TagBits.AnnotationNullable) != 0)
284
			return FlowInfo.POTENTIALLY_NULL;
284
			return FlowInfo.POTENTIALLY_NULL | FlowInfo.POTENTIALLY_NON_NULL;
285
	}
285
	}
286
	return FlowInfo.UNKNOWN;
286
	return FlowInfo.UNKNOWN;
287
}
287
}

Return to bug 365387