Lines 7357-7362
Link Here
|
7357 |
" Set<X> channel = channels.get(0);\n" + |
7357 |
" Set<X> channel = channels.get(0);\n" + |
7358 |
" ^^^^^^^^\n" + |
7358 |
" ^^^^^^^^\n" + |
7359 |
"channels cannot be resolved\n" + |
7359 |
"channels cannot be resolved\n" + |
|
|
7360 |
"----------\n" + |
7361 |
"2. WARNING in X.java (at line 7)\n" + |
7362 |
" element = (Set<X>) iter.next();\n" + |
7363 |
" ^^^^^^^^^^^^^^^^^^^^\n" + |
7364 |
"Type safety: The cast from X to Set<X> is actually checking against the erased type Set\n" + |
7360 |
"----------\n"); |
7365 |
"----------\n"); |
7361 |
} |
7366 |
} |
7362 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=70243 unsafe cast when wildcards |
7367 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=70243 unsafe cast when wildcards |
Lines 26562-26570
Link Here
|
26562 |
"1. WARNING in X.java (at line 5)\n" + |
26567 |
"1. WARNING in X.java (at line 5)\n" + |
26563 |
" return (Bar<Object>)f;\n" + |
26568 |
" return (Bar<Object>)f;\n" + |
26564 |
" ^^^^^^^^^^^^^^\n" + |
26569 |
" ^^^^^^^^^^^^^^\n" + |
|
|
26570 |
"Type safety: The cast from Foo to Bar<Object> is actually checking against the erased type Bar\n" + |
26571 |
"----------\n" + |
26572 |
"2. WARNING in X.java (at line 5)\n" + |
26573 |
" return (Bar<Object>)f;\n" + |
26574 |
" ^^^^^^^^^^^^^^\n" + |
26565 |
"Unnecessary cast from Foo to Bar<Object>\n" + |
26575 |
"Unnecessary cast from Foo to Bar<Object>\n" + |
26566 |
"----------\n" + |
26576 |
"----------\n" + |
26567 |
"2. ERROR in X.java (at line 7)\n" + |
26577 |
"3. ERROR in X.java (at line 7)\n" + |
26568 |
" Zork z;\n" + |
26578 |
" Zork z;\n" + |
26569 |
" ^^^^\n" + |
26579 |
" ^^^^\n" + |
26570 |
"Zork cannot be resolved to a type\n" + |
26580 |
"Zork cannot be resolved to a type\n" + |
Lines 34170-34173
Link Here
|
34170 |
}, |
34180 |
}, |
34171 |
""); |
34181 |
""); |
34172 |
} |
34182 |
} |
|
|
34183 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148041 |
34184 |
public void test1062() { |
34185 |
this.runNegativeTest( |
34186 |
new String[] { |
34187 |
"X.java", // ================= |
34188 |
"import java.util.HashSet;\n" + |
34189 |
"import java.util.Iterator;\n" + |
34190 |
"import java.util.Set;\n" + |
34191 |
"\n" + |
34192 |
"public class X {\n" + |
34193 |
" public static void main(String[] args) {\n" + |
34194 |
" Set<X> set = new HashSet<X>();\n" + |
34195 |
" for (Iterator<X> iterator = set.iterator(); iterator.hasNext();) {\n" + |
34196 |
" Set<X> element1 = iterator.next();\n" + |
34197 |
" Set<X> element2 = (Set<X>) iterator.next(); // warning\n" + |
34198 |
" }\n" + |
34199 |
" }\n" + |
34200 |
"}", // ================= |
34201 |
}, |
34202 |
"----------\n" + |
34203 |
"1. ERROR in X.java (at line 9)\n" + |
34204 |
" Set<X> element1 = iterator.next();\n" + |
34205 |
" ^^^^^^^^^^^^^^^\n" + |
34206 |
"Type mismatch: cannot convert from X to Set<X>\n" + |
34207 |
"----------\n" + |
34208 |
"2. WARNING in X.java (at line 10)\n" + |
34209 |
" Set<X> element2 = (Set<X>) iterator.next(); // warning\n" + |
34210 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
34211 |
"Type safety: The cast from X to Set<X> is actually checking against the erased type Set\n" + |
34212 |
"----------\n"); |
34213 |
} |
34214 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148041 - variation |
34215 |
public void test1063() { |
34216 |
this.runNegativeTest( |
34217 |
new String[] { |
34218 |
"X.java", // ================= |
34219 |
"import java.util.HashSet;\n" + |
34220 |
"import java.util.Iterator;\n" + |
34221 |
"import java.util.Set;\n" + |
34222 |
"\n" + |
34223 |
"public class X {\n" + |
34224 |
" public static void main(String[] args) {\n" + |
34225 |
" Set<Cloneable> set = new HashSet<Cloneable>();\n" + |
34226 |
" for (Iterator<Cloneable> iterator = set.iterator(); iterator.hasNext();) {\n" + |
34227 |
" Set<Cloneable> element1 = iterator.next();\n" + |
34228 |
" Set<Cloneable> element2 = (Set<Cloneable>) iterator.next(); // warning\n" + |
34229 |
" }\n" + |
34230 |
" }\n" + |
34231 |
"}", // ================= |
34232 |
}, |
34233 |
"----------\n" + |
34234 |
"1. ERROR in X.java (at line 9)\n" + |
34235 |
" Set<Cloneable> element1 = iterator.next();\n" + |
34236 |
" ^^^^^^^^^^^^^^^\n" + |
34237 |
"Type mismatch: cannot convert from Cloneable to Set<Cloneable>\n" + |
34238 |
"----------\n" + |
34239 |
"2. WARNING in X.java (at line 10)\n" + |
34240 |
" Set<Cloneable> element2 = (Set<Cloneable>) iterator.next(); // warning\n" + |
34241 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
34242 |
"Type safety: The cast from Cloneable to Set<Cloneable> is actually checking against the erased type Set\n" + |
34243 |
"----------\n"); |
34244 |
} |
34245 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=148041 - variation |
34246 |
public void test1064() { |
34247 |
this.runNegativeTest( |
34248 |
new String[] { |
34249 |
"X.java", // ================= |
34250 |
"import java.util.HashSet;\n" + |
34251 |
"import java.util.Iterator;\n" + |
34252 |
"\n" + |
34253 |
"public class X {\n" + |
34254 |
" public static void main(String[] args) {\n" + |
34255 |
" HashSet<X> set = new HashSet<X>();\n" + |
34256 |
" for (Iterator<X> iterator = set.iterator(); iterator.hasNext();) {\n" + |
34257 |
" HashSet<X> element1 = iterator.next();\n" + |
34258 |
" HashSet<X> element2 = (HashSet<X>) iterator.next();\n" + |
34259 |
" }\n" + |
34260 |
" }\n" + |
34261 |
"}", // ================= |
34262 |
}, |
34263 |
"----------\n" + |
34264 |
"1. ERROR in X.java (at line 8)\n" + |
34265 |
" HashSet<X> element1 = iterator.next();\n" + |
34266 |
" ^^^^^^^^^^^^^^^\n" + |
34267 |
"Type mismatch: cannot convert from X to HashSet<X>\n" + |
34268 |
"----------\n" + |
34269 |
"2. ERROR in X.java (at line 9)\n" + |
34270 |
" HashSet<X> element2 = (HashSet<X>) iterator.next();\n" + |
34271 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
34272 |
"Cannot cast from X to HashSet<X>\n" + |
34273 |
"----------\n"); |
34274 |
} |
34173 |
} |
34275 |
} |