1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
// Test case from
// http://stackoverflow.com/questions/38339332/in-a-bounded-wildcard-where-does-the-annotation-belong
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
class Styleable {}
class BoundedWildcardTest {
private void locChildren(Styleable c) {
// ...
}
public void initLoc(List<? extends Styleable> s) {
for (Styleable c : s) {
locChildren(c);
}
}
// :: error: (bound.type.incompatible)
public void initLoc1(@Nullable List<@Nullable ? extends Styleable> s) {
// :: error: (iterating.over.nullable)
for (Styleable c : s) {
locChildren(c);
}
}
public void initLoc2(@Nullable List<@Nullable ? extends @Nullable Styleable> s) {
// :: error: (iterating.over.nullable)
for (Styleable c : s) {
// :: error: argument.type.incompatible
locChildren(c);
}
}
public void initLoc3(@Nullable List<? extends @Nullable Styleable> s) {
// :: error: (iterating.over.nullable)
for (Styleable c : s) {
// :: error: argument.type.incompatible
locChildren(c);
}
}
}
|