File: Issue1809.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 (36 lines) | stat: -rw-r--r-- 882 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
32
33
34
35
36
// Test case for Issue 1809:
// https://github.com/typetools/checker-framework/issues/1809

// Note that -AatfCacheSize=5 is required to exercise the problem.
// This test is to ensure the basic code compiles.
// For a reproduction of the issue, see checker/jtreg/nullness/Issue1809.java

import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

@SuppressWarnings("unchecked")
abstract class Issue1809 {

    abstract <T> Stream<T> concat(Stream<? extends T>... streams);

    abstract Optional<A> f();

    private static class A {}

    interface B {
        List<C> g();
    }

    interface C {
        List<S> h();
    }

    interface S {}

    private Stream<A> xrefsFor(B b) {
        return concat(b.g().stream().flatMap(a -> a.h().stream().map(c -> f())))
                .filter(Optional::isPresent)
                .map(Optional::get);
    }
}