File: ReceiversLambda.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 (31 lines) | stat: -rw-r--r-- 867 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
// Test references to this and super in a lambda.

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

// Tests for the nullable type system
interface SupplierR {
    @NonNull ReceiverTest supply();
}

interface FunctionRT<T extends @Nullable Object, R> {
    R apply(T t);
}

class ReceiverTest {

    // :: error: (method.invocation.invalid)
    FunctionRT<String, String> f1 = s -> this.toString();
    // :: error: (method.invocation.invalid)
    FunctionRT<String, String> f2 = s -> super.toString();

    void context1(@NonNull ReceiverTest this) {
        SupplierR s = () -> this;
    }

    void context2(@Nullable ReceiverTest this) {
        // TODO: This is bug that is not specific to lambdas
        // https://github.com/typetools/checker-framework/issues/352
        // :: error: (return.type.incompatible)
        SupplierR s = () -> this;
    }
}