Debian Codegraph @

checker/tests/nullness/java8inference/FalsePositives.java

raw
1 // Some of these code was submitted in #1384.
2 // https://github.com/typetools/checker-framework/issues/1384
3 // Other parts are from the following comment.
4 // https://github.com/typetools/checker-framework/pull/1387#issuecomment-316147360
5 // The rest is from plume-lib.
6
7 import java.util.Arrays;
8 import java.util.List;
9 import java.util.Queue;
10
11 public class FalsePositives {
12 static class Partitioning<F> {}
13
14 public static <T> List<Partitioning<T>> partitionInto(Queue<T> elts, int k) {
15 if (elts.size() < k) {
16 throw new IllegalArgumentException();
17 }
18 return partitionIntoHelper(elts, Arrays.asList(new Partitioning<T>()), k, 0);
19 }
20
21 public static <T> List<Partitioning<T>> partitionIntoHelper(
22 Queue<T> elts,
23 List<Partitioning<T>> resultSoFar,
24 int numEmptyParts,
25 int numNonemptyParts) {
26 throw new RuntimeException();
27 }
28
29 interface Box<T> {}
30
31 interface Function<P, R> {
32 R apply(P p);
33 }
34
35 interface Utils {
36 <I, O> Box<O> foo(Box<I> input, Function<? super I, ? extends O> function);
37
38 <I, O> Function<I, O> bar(Function<? super I, ? extends O> function);
39 }
40
41 class Test {
42 Box<Integer> demo(Utils u, Box<String> bs) {
43 return u.foo(bs, u.bar((String s) -> 5));
44 }
45
46 Integer ugh(String n) {
47 return 5;
48 }
49
50 Box<Integer> demo2(Utils u, Box<String> bs) {
51 return u.foo(bs, u.bar(this::ugh));
52 }
53 }
54
55 abstract class Test2 {
56 abstract <T> Box<Box<T>> foo(Box<? extends Box<? extends T>> p);
57
58 abstract <T> Box<Box<T>> bar(Function<Number, T> f);
59
60 abstract String baz(Number p);
61
62 Box<Box<String>> demo() {
63 return foo(bar(this::baz));
64 }
65 }
66 }