| 1 |
import org.checkerframework.checker.nullness.qual.Nullable; |
| 2 |
|
| 3 |
class InLambdaAnnotated { |
| 4 |
static class Mine<T> { |
| 5 |
@SuppressWarnings("nullness") // just a utility |
| 6 |
static <S> Mine<S> some() { |
| 7 |
return null; |
| 8 |
} |
| 9 |
} |
| 10 |
|
| 11 |
interface Function<T, R> { |
| 12 |
R apply(T t); |
| 13 |
} |
| 14 |
|
| 15 |
interface Box<V> {} |
| 16 |
|
| 17 |
static class Boxes { |
| 18 |
@SuppressWarnings("nullness") // just a utility |
| 19 |
static <O> Box<O> transform(Function<String, ? extends O> function) { |
| 20 |
return null; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
class Infer { |
| 25 |
// The nested Mine.some() needs to infer the right type. |
| 26 |
Box<Mine<@Nullable Integer>> g = |
| 27 |
// TODO: This is a false positive. |
| 28 |
// :: error: (assignment.type.incompatible) |
| 29 |
Boxes.transform( |
| 30 |
el -> { |
| 31 |
return Mine.some(); |
| 32 |
}); |
| 33 |
|
| 34 |
void bar(Function<String, Mine<@Nullable Integer>> fun) { |
| 35 |
Box<Mine<@Nullable Integer>> h = Boxes.transform(fun); |
| 36 |
} |
| 37 |
} |
| 38 |
} |