Debian Codegraph @

checker/tests/nullness/generics/WellformedBounds.java

raw
1 import org.checkerframework.checker.nullness.qual.*;
2
3 // Field f needs to be set, b/c the upper bound is @Initialized
4 // :: error: (initialization.fields.uninitialized)
5 class Param<T extends @NonNull Object> {
6 T f;
7
8 void foo() {
9 // Valid, because upper bound is @Initialized @NonNull
10 f.toString();
11 }
12 }
13
14 // :: error: (type.argument.type.incompatible)
15 class Invalid<S extends Param<@Nullable Object>> {
16 void bar(S s) {
17 s.foo();
18 }
19
20 // :: error: (type.argument.type.incompatible)
21 <M extends Param<@Nullable Object>> void foobar(M p) {}
22 }
23
24 interface ParamI<T extends @NonNull Object> {}
25
26 class Invalid2<
27 S extends
28 Number &
29 // :: error: (type.argument.type.incompatible)
30 ParamI<@Nullable Object>> {}
31
32 class Invalid3 {
33 <
34 M extends
35 Number &
36 // :: error: (type.argument.type.incompatible)
37 ParamI<@Nullable Object>>
38 void foobar(M p) {}
39 }