Debian Codegraph @

checker/tests/nullness/generics/BoundedWildcardTest.java

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