File: MemberReferences.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (47 lines) | stat: -rw-r--r-- 1,483 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
45
46
47
import org.checkerframework.checker.nullness.qual.*;

abstract class References {

    void context(References c) {

        // No error
        FuncA funcA1 = References::aMethod1;
        // No error, covariant parameters
        FuncA funcA2 = References::aMethod2;
        // :: error: (methodref.return.invalid)
        FuncA funcA3 = References::aMethod3;
        // :: error: (methodref.return.invalid)
        FuncA funcA4 = References::aMethod4;

        // :: error: (methodref.param.invalid)
        FuncB funcB1 = References::aMethod1;
        // No error
        FuncB funcB2 = References::aMethod2;
        // :: error: (methodref.return.invalid) :: error: (methodref.param.invalid)
        FuncB funcB3 = References::aMethod3;
        // :: error: (methodref.return.invalid)
        FuncB funcB4 = References::aMethod4;

        FuncA typeArg1 = References::<@NonNull String>aMethod5;
        // :: error: (methodref.param.invalid)
        FuncB typeArg2 = References::<@NonNull String>aMethod5;
    }

    abstract @NonNull String aMethod1(@NonNull String s);

    abstract @NonNull String aMethod2(@Nullable String s);

    abstract @Nullable String aMethod3(@NonNull String s);

    abstract @Nullable String aMethod4(@Nullable String s);

    abstract <T> T aMethod5(T t);

    interface FuncA {
        @NonNull String method(References a, @NonNull String b);
    }

    interface FuncB {
        @NonNull String method(References a, @Nullable String b);
    }
}