| 1 |
// Test case for Issue 979: |
| 2 |
// https://github.com/typetools/checker-framework/issues/979 |
| 3 |
|
| 4 |
class MyStream<T> { |
| 5 |
@SuppressWarnings("nullness") |
| 6 |
<R, A> R collect(MyCollector<? super T, A, R> collector) { |
| 7 |
return null; |
| 8 |
} |
| 9 |
} |
| 10 |
|
| 11 |
interface MyCollector<T, A, R> {} |
| 12 |
|
| 13 |
class Inference { |
| 14 |
|
| 15 |
@SuppressWarnings("nullness") |
| 16 |
static <E> MyCollector<E, ?, MyStream<E>> toImmutableStream() { |
| 17 |
return null; |
| 18 |
} |
| 19 |
|
| 20 |
MyStream<String> test(MyStream<String> p) { |
| 21 |
/* Need Java 8 assignment context to correctly infer type arguments. |
| 22 |
return p.collect(toImmutableStream()); |
| 23 |
^ |
| 24 |
found : @Initialized @NonNull MyStream<? extends @Initialized @Nullable Object> |
| 25 |
required: @Initialized @NonNull MyStream<@Initialized @NonNull String> |
| 26 |
*/ |
| 27 |
return p.collect(toImmutableStream()); |
| 28 |
} |
| 29 |
} |