|
Lines 36-42
public NullAnnotationTest(String name) {
Link Here
|
| 36 |
// Static initializer to specify tests subset using TESTS_* static variables |
36 |
// Static initializer to specify tests subset using TESTS_* static variables |
| 37 |
// All specified tests which do not belong to the class are skipped... |
37 |
// All specified tests which do not belong to the class are skipped... |
| 38 |
static { |
38 |
static { |
| 39 |
// TESTS_NAMES = new String[] { "testBug412076" }; |
39 |
TESTS_NAMES = new String[] { "testBug434604" }; |
| 40 |
// TESTS_NUMBERS = new int[] { 561 }; |
40 |
// TESTS_NUMBERS = new int[] { 561 }; |
| 41 |
// TESTS_RANGE = new int[] { 1, 2049 }; |
41 |
// TESTS_RANGE = new int[] { 1, 2049 }; |
| 42 |
} |
42 |
} |
|
Lines 7436-7439
public void testBug434374c() {
Link Here
|
| 7436 |
getCompilerOptions(), |
7436 |
getCompilerOptions(), |
| 7437 |
""); |
7437 |
""); |
| 7438 |
} |
7438 |
} |
|
|
7439 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=434602 |
| 7440 |
// Possible error with inferred null annotations leading to contradictory null annotations |
| 7441 |
public void testBug434602() { |
| 7442 |
if (this.complianceLevel < ClassFileConstants.JDK1_8) |
| 7443 |
return; |
| 7444 |
runConformTestWithLibs( |
| 7445 |
new String[] { |
| 7446 |
"X.java", |
| 7447 |
"import org.eclipse.jdt.annotation.NonNullByDefault;\n" + |
| 7448 |
"import org.eclipse.jdt.annotation.Nullable;\n" + |
| 7449 |
"\n" + |
| 7450 |
"class Y {}\n" + |
| 7451 |
"@NonNullByDefault\n" + |
| 7452 |
"class X {\n" + |
| 7453 |
" void foo() {\n" + |
| 7454 |
" X x = new X();\n" + |
| 7455 |
" x.bar(); // Error: Contradictory null annotations before the fix\n" + |
| 7456 |
" }\n" + |
| 7457 |
"\n" + |
| 7458 |
" public <T extends Y> @Nullable T bar() {\n" + |
| 7459 |
" return null;\n" + |
| 7460 |
" }\n" + |
| 7461 |
"}\n" |
| 7462 |
}, |
| 7463 |
getCompilerOptions(), |
| 7464 |
""); |
| 7465 |
} |
| 7466 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=434602 |
| 7467 |
//Possible error with inferred null annotations leading to contradictory null annotations |
| 7468 |
//Method part of parameterized class. |
| 7469 |
public void testBug434603() { |
| 7470 |
if (this.complianceLevel < ClassFileConstants.JDK1_8) |
| 7471 |
return; |
| 7472 |
runConformTestWithLibs( |
| 7473 |
new String[] { |
| 7474 |
"X.java", |
| 7475 |
"import org.eclipse.jdt.annotation.NonNullByDefault;\n" + |
| 7476 |
"import org.eclipse.jdt.annotation.Nullable;\n" + |
| 7477 |
"\n" + |
| 7478 |
"class Y {}\n" + |
| 7479 |
"@NonNullByDefault\n" + |
| 7480 |
"class Z <T> {\n" + |
| 7481 |
" void foo() {\n" + |
| 7482 |
" Z<Y> z = new Z<Y>();\n" + |
| 7483 |
" z.bar(); // Error: Contradictory null annotations before the fix\n" + |
| 7484 |
" }\n" + |
| 7485 |
"\n" + |
| 7486 |
" public @Nullable T bar() {\n" + |
| 7487 |
" return null;\n" + |
| 7488 |
" }\n" + |
| 7489 |
"}\n" + |
| 7490 |
"class X {}\n" |
| 7491 |
}, |
| 7492 |
getCompilerOptions(), |
| 7493 |
""); |
| 7494 |
} |
| 7495 |
public void testBug434604() { |
| 7496 |
if (this.complianceLevel < ClassFileConstants.JDK1_8) |
| 7497 |
return; |
| 7498 |
runConformTestWithLibs( |
| 7499 |
new String[] { |
| 7500 |
"X.java", |
| 7501 |
"//import org.eclipse.jdt.annotation.NonNullByDefault;\n" + |
| 7502 |
"import org.eclipse.jdt.annotation.Nullable;\n" + |
| 7503 |
"import org.eclipse.jdt.annotation.NonNull;\n" + |
| 7504 |
"\n" + |
| 7505 |
"class Y {}\n" + |
| 7506 |
"class Y2 extends Y {}\n" + |
| 7507 |
"\n" + |
| 7508 |
"//@NonNullByDefault\n" + |
| 7509 |
"class X {\n" + |
| 7510 |
" void foo() {\n" + |
| 7511 |
" X x = new X();\n" + |
| 7512 |
" x.bar(new Y2()); \n" + |
| 7513 |
" }\n" + |
| 7514 |
" public <T extends @NonNull Y> @Nullable T bar(T t) {\n" + |
| 7515 |
" return t;\n" + |
| 7516 |
" }\n" + |
| 7517 |
"}\n" |
| 7518 |
}, |
| 7519 |
getCompilerOptions(), |
| 7520 |
""); |
| 7521 |
} |
| 7439 |
} |
7522 |
} |