| 1 |
// Test references to this and super in a lambda. |
| 2 |
|
| 3 |
import org.checkerframework.checker.nullness.qual.*; |
| 4 |
|
| 5 |
// Tests for the nullable type system |
| 6 |
interface SupplierR { |
| 7 |
@NonNull ReceiverTest supply(); |
| 8 |
} |
| 9 |
|
| 10 |
interface FunctionRT<T extends @Nullable Object, R> { |
| 11 |
R apply(T t); |
| 12 |
} |
| 13 |
|
| 14 |
class ReceiverTest { |
| 15 |
|
| 16 |
// :: error: (method.invocation.invalid) |
| 17 |
FunctionRT<String, String> f1 = s -> this.toString(); |
| 18 |
// :: error: (method.invocation.invalid) |
| 19 |
FunctionRT<String, String> f2 = s -> super.toString(); |
| 20 |
|
| 21 |
void context1(@NonNull ReceiverTest this) { |
| 22 |
SupplierR s = () -> this; |
| 23 |
} |
| 24 |
|
| 25 |
void context2(@Nullable ReceiverTest this) { |
| 26 |
// TODO: This is bug that is not specific to lambdas |
| 27 |
// https://github.com/typetools/checker-framework/issues/352 |
| 28 |
// :: error: (return.type.incompatible) |
| 29 |
SupplierR s = () -> this; |
| 30 |
} |
| 31 |
} |