Lines 17-22
Link Here
|
17 |
* bug 338303 - Warning about Redundant assignment conflicts with definite assignment |
17 |
* bug 338303 - Warning about Redundant assignment conflicts with definite assignment |
18 |
* bug 336428 - [compiler][null] bogus warning "redundant null check" in condition of do {} while() loop |
18 |
* bug 336428 - [compiler][null] bogus warning "redundant null check" in condition of do {} while() loop |
19 |
* bug 324178 - [null] ConditionalExpression.nullStatus(..) doesn't take into account the analysis of condition itself |
19 |
* bug 324178 - [null] ConditionalExpression.nullStatus(..) doesn't take into account the analysis of condition itself |
|
|
20 |
* bug 354554 - [null] conditional with redundant condition yields weak error message |
20 |
*******************************************************************************/ |
21 |
*******************************************************************************/ |
21 |
package org.eclipse.jdt.core.tests.compiler.regression; |
22 |
package org.eclipse.jdt.core.tests.compiler.regression; |
22 |
|
23 |
|
Lines 14898-14901
Link Here
|
14898 |
"----------\n"); |
14899 |
"----------\n"); |
14899 |
} |
14900 |
} |
14900 |
} |
14901 |
} |
|
|
14902 |
// Bug 354554 - [null] conditional with redundant condition yields weak error message |
14903 |
public void testBug354554() { |
14904 |
this.runNegativeTest( |
14905 |
new String[] { |
14906 |
"Bug354554.java", |
14907 |
"public class Bug354554{\n" + |
14908 |
" void foo() {\n" + |
14909 |
" Object u = new Object();\n" + |
14910 |
" Object r = (u == null ? u : null);\n" + // condition is always false - should not spoil subsequent null-analysis |
14911 |
" System.out.println(r.toString());\n" + // should strongly complain: r is definitely null |
14912 |
" }\n" + |
14913 |
"}\n" |
14914 |
}, |
14915 |
"----------\n" + |
14916 |
"1. ERROR in Bug354554.java (at line 4)\n" + |
14917 |
" Object r = (u == null ? u : null);\n" + |
14918 |
" ^\n" + |
14919 |
"Null comparison always yields false: The variable u cannot be null at this location\n" + |
14920 |
"----------\n" + |
14921 |
"2. ERROR in Bug354554.java (at line 5)\n" + |
14922 |
" System.out.println(r.toString());\n" + |
14923 |
" ^\n" + |
14924 |
"Null pointer access: The variable r can only be null at this location\n" + |
14925 |
"----------\n"); |
14926 |
} |
14927 |
//Bug 354554 - [null] conditional with redundant condition yields weak error message |
14928 |
public void testBug354554b() { |
14929 |
this.runNegativeTest( |
14930 |
new String[] { |
14931 |
"Bug354554.java", |
14932 |
"public class Bug354554{\n" + |
14933 |
" void foo() {\n" + |
14934 |
" Object u = new Object();\n" + |
14935 |
" Object r = (u != null ? u : null);\n" + // condition is always true - should not spoil subsequent null-analysis |
14936 |
" System.out.println(r.toString());\n" + // don't complain: r is definitely non-null |
14937 |
" }\n" + |
14938 |
"}\n" |
14939 |
}, |
14940 |
"----------\n" + |
14941 |
"1. ERROR in Bug354554.java (at line 4)\n" + |
14942 |
" Object r = (u != null ? u : null);\n" + |
14943 |
" ^\n" + |
14944 |
"Redundant null check: The variable u cannot be null at this location\n" + |
14945 |
"----------\n"); |
14946 |
} |
14901 |
} |
14947 |
} |