Debian Codegraph @

checker/tests/nullness/java8/methodref/PolyNullness.java

raw
1 import org.checkerframework.checker.nullness.qual.*;
2
3 interface PolyFunc {
4 @PolyNull String method(@PolyNull String in);
5 }
6
7 interface NonNullFunc {
8 @NonNull String method(@NonNull String in);
9 }
10
11 interface MixedFunc {
12 @NonNull String method(@Nullable String in);
13 }
14
15 class Context {
16
17 static @PolyNull String poly(@PolyNull String in) {
18 return in;
19 }
20
21 static String nonPoly(String in) {
22 return in;
23 }
24
25 void context() {
26 PolyFunc f1 = Context::poly;
27 // :: error: (methodref.param.invalid)
28 PolyFunc f2 = Context::nonPoly;
29
30 NonNullFunc f3 = Context::poly;
31 // :: error: (methodref.return.invalid)
32 MixedFunc f4 = Context::poly;
33 }
34 }