Lines 5304-5324
Link Here
|
5304 |
" }\n" + |
5304 |
" }\n" + |
5305 |
"}\n", |
5305 |
"}\n", |
5306 |
}, |
5306 |
}, |
5307 |
"----------\n" + |
5307 |
"----------\n" + |
5308 |
"1. ERROR in X.java (at line 4)\n" + |
5308 |
"1. ERROR in X.java (at line 4)\n" + |
5309 |
" if (t instanceof X<T>) {\n" + |
5309 |
" if (t instanceof X<T>) {\n" + |
5310 |
" ^^^^^^^^^^^^^^\n" + |
5310 |
" ^^^^^^^^^^^^^^\n" + |
5311 |
"Cannot perform instanceof check against parameterized type X<T>. Use instead its raw form X since generic type information will be erased at runtime\n" + |
5311 |
"Cannot perform instanceof check against parameterized type X<T>. Use instead its raw form X since generic type information will be erased at runtime\n" + |
5312 |
"----------\n" + |
5312 |
"----------\n" + |
5313 |
"2. ERROR in X.java (at line 6)\n" + |
5313 |
"2. ERROR in X.java (at line 6)\n" + |
5314 |
" } else if (t instanceof X<String>) {\n" + |
5314 |
" } else if (t instanceof X<String>) {\n" + |
5315 |
" ^^^^^^^^^^^^^^\n" + |
5315 |
" ^^^^^^^^^^^^^^\n" + |
5316 |
"Cannot perform instanceof check against parameterized type X<String>. Use instead its raw form X since generic type information will be erased at runtime\n" + |
5316 |
"Cannot perform instanceof check against parameterized type X<String>. Use instead its raw form X since generic type information will be erased at runtime\n" + |
5317 |
"----------\n" + |
5317 |
"----------\n" + |
5318 |
"3. ERROR in X.java (at line 10)\n" + |
5318 |
"3. ERROR in X.java (at line 10)\n" + |
5319 |
" } else if (t instanceof T) {\n" + |
5319 |
" } else if (t instanceof T) {\n" + |
5320 |
" ^^^^^^^^^^^^^^\n" + |
5320 |
" ^^^^^^^^^^^^^^\n" + |
5321 |
"Cannot perform instanceof check against type parameter T. Use instead its erasure Object since generic type information will be erased at runtime\n" + |
5321 |
"Cannot perform instanceof check against type parameter T. Use instead its erasure Object since generic type information will be erased at runtime\n" + |
|
|
5322 |
"----------\n" + |
5323 |
"4. WARNING in X.java (at line 12)\n" + |
5324 |
" } else if (t instanceof X) {\n" + |
5325 |
" ^\n" + |
5326 |
"X is a raw type. References to generic type X<T> should be parameterized\n" + |
5322 |
"----------\n", |
5327 |
"----------\n", |
5323 |
null, |
5328 |
null, |
5324 |
true, |
5329 |
true, |
Lines 26270-26276
Link Here
|
26270 |
}, |
26275 |
}, |
26271 |
""); |
26276 |
""); |
26272 |
} |
26277 |
} |
26273 |
// ensure no raw type ref complaint inside instanceof / cast |
26278 |
|
26274 |
public void test0830() { |
26279 |
public void test0830() { |
26275 |
this.runNegativeTest( |
26280 |
this.runNegativeTest( |
26276 |
new String[] { |
26281 |
new String[] { |
Lines 26288-26328
Link Here
|
26288 |
" }\n" + |
26293 |
" }\n" + |
26289 |
"}\n", |
26294 |
"}\n", |
26290 |
}, |
26295 |
}, |
26291 |
"----------\n" + |
26296 |
"----------\n" + |
26292 |
"1. WARNING in X.java (at line 5)\n" + |
26297 |
"1. WARNING in X.java (at line 4)\n" + |
26293 |
" X x = (X) o;\n" + |
26298 |
" boolean b = o instanceof X;\n" + |
26294 |
" ^\n" + |
26299 |
" ^\n" + |
26295 |
"X is a raw type. References to generic type X<T> should be parameterized\n" + |
26300 |
"X is a raw type. References to generic type X<T> should be parameterized\n" + |
26296 |
"----------\n" + |
26301 |
"----------\n" + |
26297 |
"2. WARNING in X.java (at line 5)\n" + |
26302 |
"2. WARNING in X.java (at line 5)\n" + |
26298 |
" X x = (X) o;\n" + |
26303 |
" X x = (X) o;\n" + |
26299 |
" ^\n" + |
26304 |
" ^\n" + |
26300 |
"X is a raw type. References to generic type X<T> should be parameterized\n" + |
26305 |
"X is a raw type. References to generic type X<T> should be parameterized\n" + |
26301 |
"----------\n" + |
26306 |
"----------\n" + |
26302 |
"3. WARNING in X.java (at line 6)\n" + |
26307 |
"3. WARNING in X.java (at line 5)\n" + |
26303 |
" X<String> xs = (X<String>)o;\n" + |
26308 |
" X x = (X) o;\n" + |
26304 |
" ^^^^^^^^^^^^\n" + |
26309 |
" ^\n" + |
26305 |
"Type safety: Unchecked cast from Object to X<String>\n" + |
26310 |
"X is a raw type. References to generic type X<T> should be parameterized\n" + |
26306 |
"----------\n" + |
26311 |
"----------\n" + |
26307 |
"4. ERROR in X.java (at line 7)\n" + |
26312 |
"4. WARNING in X.java (at line 6)\n" + |
26308 |
" Zork z;\n" + |
26313 |
" X<String> xs = (X<String>)o;\n" + |
26309 |
" ^^^^\n" + |
26314 |
" ^^^^^^^^^^^^\n" + |
26310 |
"Zork cannot be resolved to a type\n" + |
26315 |
"Type safety: Unchecked cast from Object to X<String>\n" + |
26311 |
"----------\n" + |
26316 |
"----------\n" + |
26312 |
"5. WARNING in X.java (at line 10)\n" + |
26317 |
"5. ERROR in X.java (at line 7)\n" + |
26313 |
" List l = (List) al;\n" + |
26318 |
" Zork z;\n" + |
26314 |
" ^^^^\n" + |
26319 |
" ^^^^\n" + |
26315 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
26320 |
"Zork cannot be resolved to a type\n" + |
26316 |
"----------\n" + |
26321 |
"----------\n" + |
26317 |
"6. WARNING in X.java (at line 10)\n" + |
26322 |
"6. WARNING in X.java (at line 10)\n" + |
26318 |
" List l = (List) al;\n" + |
26323 |
" List l = (List) al;\n" + |
26319 |
" ^^^^^^^^^\n" + |
26324 |
" ^^^^\n" + |
26320 |
"Unnecessary cast from ArrayList<String> to List\n" + |
26325 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
26321 |
"----------\n" + |
26326 |
"----------\n" + |
26322 |
"7. WARNING in X.java (at line 10)\n" + |
26327 |
"7. WARNING in X.java (at line 10)\n" + |
26323 |
" List l = (List) al;\n" + |
26328 |
" List l = (List) al;\n" + |
26324 |
" ^^^^\n" + |
26329 |
" ^^^^^^^^^\n" + |
26325 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
26330 |
"Unnecessary cast from ArrayList<String> to List\n" + |
|
|
26331 |
"----------\n" + |
26332 |
"8. WARNING in X.java (at line 10)\n" + |
26333 |
" List l = (List) al;\n" + |
26334 |
" ^^^^\n" + |
26335 |
"List is a raw type. References to generic type List<E> should be parameterized\n" + |
26326 |
"----------\n"); |
26336 |
"----------\n"); |
26327 |
} |
26337 |
} |
26328 |
//unnecessary cast may be combined with unchecked cast warning |
26338 |
//unnecessary cast may be combined with unchecked cast warning |
Lines 47203-47206
Link Here
|
47203 |
}, |
47213 |
}, |
47204 |
""); |
47214 |
""); |
47205 |
} |
47215 |
} |
|
|
47216 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 |
47217 |
public void test1398() throws Exception { |
47218 |
this.runNegativeTest( |
47219 |
new String[] { |
47220 |
"A.java", |
47221 |
"public class A<T> {\n" + |
47222 |
" void f() {\n" + |
47223 |
" boolean b=null instanceof A; \n" + |
47224 |
" Zork z;\n" + |
47225 |
" }\n" + |
47226 |
"}\n", |
47227 |
}, |
47228 |
"----------\n" + |
47229 |
"1. WARNING in A.java (at line 3)\n" + |
47230 |
" boolean b=null instanceof A; \n" + |
47231 |
" ^\n" + |
47232 |
"A is a raw type. References to generic type A<T> should be parameterized\n" + |
47233 |
"----------\n" + |
47234 |
"2. ERROR in A.java (at line 4)\n" + |
47235 |
" Zork z;\n" + |
47236 |
" ^^^^\n" + |
47237 |
"Zork cannot be resolved to a type\n" + |
47238 |
"----------\n"); |
47239 |
} |
47240 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation |
47241 |
public void test1399() throws Exception { |
47242 |
this.runNegativeTest( |
47243 |
new String[] { |
47244 |
"A.java", |
47245 |
"public class A<T> {\n" + |
47246 |
" void f() {\n" + |
47247 |
" boolean b=null instanceof A<?>; \n" + |
47248 |
" Zork z;\n" + |
47249 |
" }\n" + |
47250 |
"}\n", |
47251 |
}, |
47252 |
"----------\n" + |
47253 |
"1. ERROR in A.java (at line 4)\n" + |
47254 |
" Zork z;\n" + |
47255 |
" ^^^^\n" + |
47256 |
"Zork cannot be resolved to a type\n" + |
47257 |
"----------\n"); |
47258 |
} |
47259 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation |
47260 |
public void test1400() throws Exception { |
47261 |
this.runNegativeTest( |
47262 |
new String[] { |
47263 |
"A.java", |
47264 |
"public class A<T> {\n" + |
47265 |
" void f() {\n" + |
47266 |
" Object o = (A)this; \n" + |
47267 |
" Zork z;\n" + |
47268 |
" }\n" + |
47269 |
"}\n", |
47270 |
}, |
47271 |
"----------\n" + |
47272 |
"1. WARNING in A.java (at line 3)\n" + |
47273 |
" Object o = (A)this; \n" + |
47274 |
" ^^^^^^^\n" + |
47275 |
"Unnecessary cast from A<T> to A\n" + |
47276 |
"----------\n" + |
47277 |
"2. WARNING in A.java (at line 3)\n" + |
47278 |
" Object o = (A)this; \n" + |
47279 |
" ^\n" + |
47280 |
"A is a raw type. References to generic type A<T> should be parameterized\n" + |
47281 |
"----------\n" + |
47282 |
"3. ERROR in A.java (at line 4)\n" + |
47283 |
" Zork z;\n" + |
47284 |
" ^^^^\n" + |
47285 |
"Zork cannot be resolved to a type\n" + |
47286 |
"----------\n"); |
47287 |
} |
47288 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation |
47289 |
public void test1401() throws Exception { |
47290 |
this.runNegativeTest( |
47291 |
new String[] { |
47292 |
"A.java", |
47293 |
"public class A<T> {\n" + |
47294 |
" void f() {\n" + |
47295 |
" Object o = (A<?>)this; \n" + |
47296 |
" Zork z;\n" + |
47297 |
" }\n" + |
47298 |
"}\n", |
47299 |
}, |
47300 |
"----------\n" + |
47301 |
"1. WARNING in A.java (at line 3)\n" + |
47302 |
" Object o = (A<?>)this; \n" + |
47303 |
" ^^^^^^^^^^\n" + |
47304 |
"Unnecessary cast from A<T> to A<?>\n" + |
47305 |
"----------\n" + |
47306 |
"2. ERROR in A.java (at line 4)\n" + |
47307 |
" Zork z;\n" + |
47308 |
" ^^^^\n" + |
47309 |
"Zork cannot be resolved to a type\n" + |
47310 |
"----------\n"); |
47311 |
} |
47312 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation |
47313 |
public void test1402() throws Exception { |
47314 |
this.runNegativeTest( |
47315 |
new String[] { |
47316 |
"A.java", |
47317 |
"public class A<T> {\n" + |
47318 |
" void f() {\n" + |
47319 |
" Class<?> c = A.class; \n" + |
47320 |
" Zork z;\n" + |
47321 |
" }\n" + |
47322 |
"}\n", |
47323 |
}, |
47324 |
"----------\n" + |
47325 |
"1. ERROR in A.java (at line 4)\n" + |
47326 |
" Zork z;\n" + |
47327 |
" ^^^^\n" + |
47328 |
"Zork cannot be resolved to a type\n" + |
47329 |
"----------\n"); |
47330 |
} |
47331 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=252120 - variation |
47332 |
public void test1403() throws Exception { |
47333 |
this.runNegativeTest( |
47334 |
new String[] { |
47335 |
"A.java", |
47336 |
"public class A<T> {\n" + |
47337 |
" void f() {\n" + |
47338 |
" Class<?> c = A<?>.class; \n" + |
47339 |
" Zork z;\n" + |
47340 |
" }\n" + |
47341 |
"}\n", |
47342 |
}, |
47343 |
"----------\n" + |
47344 |
"1. ERROR in A.java (at line 3)\n" + |
47345 |
" Class<?> c = A<?>.class; \n" + |
47346 |
" ^\n" + |
47347 |
"Syntax error on token \"=\", ( expected after this token\n" + |
47348 |
"----------\n" + |
47349 |
"2. ERROR in A.java (at line 3)\n" + |
47350 |
" Class<?> c = A<?>.class; \n" + |
47351 |
" ^^^\n" + |
47352 |
"Syntax error on token(s), misplaced construct(s)\n" + |
47353 |
"----------\n" + |
47354 |
"3. ERROR in A.java (at line 3)\n" + |
47355 |
" Class<?> c = A<?>.class; \n" + |
47356 |
" ^^^^^\n" + |
47357 |
"Syntax error, insert \")\" to complete Expression\n" + |
47358 |
"----------\n"); |
47359 |
} |
47206 |
} |
47360 |
} |