File: BoundedWildcardTest.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (44 lines) | stat: -rw-r--r-- 1,210 bytes parent folder | download | duplicates (3)
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);
        }
    }
}