Community
Participate
Working Groups
HEAD In the code below, the two casts to (List<? extends Number>) in the receiver of the List#get(int) method and in the enhanced for loop are unnecessary, but the compiler doesn't detect this. package p; import java.util.ArrayList; import java.util.List; class A { void x() { List<? extends Number> nums = getNums(); Number num= ((List<? extends Number>) nums).get(0); for (Number n : (List<? extends Number>) nums) { System.out.println(n); } List<Number> numzzz = new ArrayList<Number>(); ((List<? super Number>) numzzz).set(0, -1); } private List getNums() { return null; } } While writing this bug, I found bug 158855 and bug 76749, which tell why some casts in the receiver are not completely unnecessary. However, in this case I don't see how class files can be affected. Note that I do get warnings when I replace all List<? extends Number> with List<Number>, so it looks like the analysis is working fine when the cast only changes type arguments. It just doesn't play wildcards.
In this case the two wildcards are seen as two different capture type bindings.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.