|
Lines 3777-3782
Link Here
|
| 3777 |
getCompilerOptions(), |
3777 |
getCompilerOptions(), |
| 3778 |
""); |
3778 |
""); |
| 3779 |
} |
3779 |
} |
|
|
3780 |
// https://bugs.eclipse.org/434899 |
| 3781 |
public void testTypeVariable6() { |
| 3782 |
runNegativeTestWithLibs( |
| 3783 |
new String[] { |
| 3784 |
"Assert.java", |
| 3785 |
"import org.eclipse.jdt.annotation.*;\n" + |
| 3786 |
"public class Assert {\n" + |
| 3787 |
" public static void caller() {\n" + |
| 3788 |
" assertNotNull(\"not null\"); // Compiler error\n" + |
| 3789 |
" assertNotNull(null); // Compiler error\n" + |
| 3790 |
" }\n" + |
| 3791 |
" private static @NonNull <T> T assertNotNull(@Nullable T object) {\n" + |
| 3792 |
" return object; // this IS bogus\n" + |
| 3793 |
" }\n" + |
| 3794 |
"}\n" |
| 3795 |
}, |
| 3796 |
getCompilerOptions(), |
| 3797 |
"----------\n" + |
| 3798 |
"1. ERROR in Assert.java (at line 8)\n" + |
| 3799 |
" return object; // this IS bogus\n" + |
| 3800 |
" ^^^^^^\n" + |
| 3801 |
"Null type mismatch (type annotations): required \'@NonNull T\' but this expression has type \'@Nullable T\'\n" + |
| 3802 |
"----------\n"); |
| 3803 |
} |
| 3804 |
// https://bugs.eclipse.org/434899 - variant which has always worked |
| 3805 |
public void testTypeVariable6a() { |
| 3806 |
runConformTestWithLibs( |
| 3807 |
new String[] { |
| 3808 |
"Assert.java", |
| 3809 |
"import org.eclipse.jdt.annotation.*;\n" + |
| 3810 |
"public class Assert {\n" + |
| 3811 |
" public static Object caller() {\n" + |
| 3812 |
" @NonNull Object result = assertNotNull(\"not null\");\n" + |
| 3813 |
" result = assertNotNull(null);\n" + |
| 3814 |
" return result;\n" + |
| 3815 |
" }\n" + |
| 3816 |
" private static @NonNull <T> T assertNotNull(@Nullable T object) {\n" + |
| 3817 |
" if (object == null) throw new NullPointerException();\n" + |
| 3818 |
" return object;\n" + |
| 3819 |
" }\n" + |
| 3820 |
"}\n" |
| 3821 |
}, |
| 3822 |
getCompilerOptions(), |
| 3823 |
""); |
| 3824 |
} |
| 3780 |
public void testSE7AnnotationCopy() { // we were dropping annotations here, but null analysis worked already since the tagbits were not "dropped", just the same capturing in a test |
3825 |
public void testSE7AnnotationCopy() { // we were dropping annotations here, but null analysis worked already since the tagbits were not "dropped", just the same capturing in a test |
| 3781 |
runNegativeTestWithLibs( |
3826 |
runNegativeTestWithLibs( |
| 3782 |
new String[] { |
3827 |
new String[] { |