File: ParametersInBody.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 (50 lines) | stat: -rw-r--r-- 1,286 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
48
49
50
// Test that parameter annotations are correct in the body of a lambda

import org.checkerframework.checker.nullness.qual.*;

interface ConsumerLPB {
    void method(@Nullable String s);
}

interface NNConsumerLPB {
    void method(@NonNull String s);
}

class LambdaParamBody {

    // :: error: (dereference.of.nullable)
    ConsumerLPB fn0 = (String i) -> i.toString();
    ConsumerLPB fn2 =
            (@Nullable String i) -> {
                // :: error: (dereference.of.nullable)
                i.toString();
            };
    ConsumerLPB fn3 =
            (String i) -> {
                // :: error: (dereference.of.nullable)
                i.toString();
            };
    ConsumerLPB fn3b =
            (i) -> {
                // :: error: (dereference.of.nullable)
                i.toString();
            };

    NNConsumerLPB fn4 =
            (String i) -> {
                i.toString();
            };
    NNConsumerLPB fn4b =
            (i) -> {
                i.toString();
            };
    NNConsumerLPB fn5 =
            (@Nullable String i) -> {
                // :: error: (dereference.of.nullable)
                i.toString();
            };
    NNConsumerLPB fn6 =
            (@NonNull String i) -> {
                i.toString();
            };
}