Debian Codegraph @

checker/tests/nullness/generics/Issue329.java

raw
1 // Test case for Issue 329:
2 // https://github.com/typetools/checker-framework/issues/329
3
4 import org.checkerframework.checker.nullness.qual.Nullable;
5
6 abstract class Issue329 {
7 interface Flag<T> {}
8
9 abstract <X> void setExtension(X value);
10
11 abstract <T> T getValue(Flag<T> flag);
12
13 void f(Flag<String> flag) {
14 String s = getValue(flag);
15 setExtension(s);
16
17 setExtension(getValue(flag));
18 }
19 }
20
21 abstract class Issue329NN {
22 interface Flag<T> {}
23
24 // Explicit bound makes it NonNull
25 abstract <X extends Object> void setExtension(X value);
26
27 abstract <T> T getValue(Flag<T> flag);
28
29 void f1(Flag<@Nullable String> flag) {
30 String s = getValue(flag);
31 // :: error: (type.argument.type.incompatible)
32 setExtension(s);
33 }
34
35 void f2(Flag<@Nullable String> flag) {
36 // TODO: false negative. See #979.
37 //// :: error: (type.argument.type.incompatible)
38 setExtension(getValue(flag));
39 }
40 }