Debian Codegraph @

checker/tests/nullness/generics/Issue269.java

raw
1 // Test case for Issue 269
2 // https://github.com/typetools/checker-framework/issues/269
3 class Repro {
4 // Implicitly G has bound @Nullable Object
5 interface Callback<G> {
6 public boolean handler(G arg);
7 }
8
9 void method1(Callback callback) {
10 // Allow this call.
11 // :: warning: [unchecked] unchecked call to handler(G) as a member of the raw type
12 // Repro.Callback
13 callback.handler(this);
14 }
15
16 // Implicitly H has bound @NonNull Object
17 interface CallbackNN<H extends Object> {
18 public boolean handler(H arg);
19 }
20
21 void method2(CallbackNN callback) {
22 // Forbid this call, because the bound is not respected.
23 // TODO: false negative. See #635.
24 //// :: error: (argument.type.incompatible)
25 // :: warning: [unchecked] unchecked call to handler(H) as a member of the raw type
26 // Repro.CallbackNN
27 callback.handler(null);
28 }
29 }