| 1 |
// Test case for Issue 1809: |
| 2 |
// https://github.com/typetools/checker-framework/issues/1809 |
| 3 |
|
| 4 |
// Note that -AatfCacheSize=5 is required to exercise the problem. |
| 5 |
// This test is to ensure the basic code compiles. |
| 6 |
// For a reproduction of the issue, see checker/jtreg/nullness/Issue1809.java |
| 7 |
|
| 8 |
import java.util.List; |
| 9 |
import java.util.Optional; |
| 10 |
import java.util.stream.Stream; |
| 11 |
|
| 12 |
@SuppressWarnings("unchecked") |
| 13 |
abstract class Issue1809 { |
| 14 |
|
| 15 |
abstract <T> Stream<T> concat(Stream<? extends T>... streams); |
| 16 |
|
| 17 |
abstract Optional<A> f(); |
| 18 |
|
| 19 |
private static class A {} |
| 20 |
|
| 21 |
interface B { |
| 22 |
List<C> g(); |
| 23 |
} |
| 24 |
|
| 25 |
interface C { |
| 26 |
List<S> h(); |
| 27 |
} |
| 28 |
|
| 29 |
interface S {} |
| 30 |
|
| 31 |
private Stream<A> xrefsFor(B b) { |
| 32 |
return concat(b.g().stream().flatMap(a -> a.h().stream().map(c -> f()))) |
| 33 |
.filter(Optional::isPresent) |
| 34 |
.map(Optional::get); |
| 35 |
} |
| 36 |
} |