File: FalsePositives.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (66 lines) | stat: -rw-r--r-- 1,818 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Some of these code was submitted in #1384.
// https://github.com/typetools/checker-framework/issues/1384
// Other parts are from the following comment.
// https://github.com/typetools/checker-framework/pull/1387#issuecomment-316147360
// The rest is from plume-lib.

import java.util.Arrays;
import java.util.List;
import java.util.Queue;

public class FalsePositives {
    static class Partitioning<F> {}

    public static <T> List<Partitioning<T>> partitionInto(Queue<T> elts, int k) {
        if (elts.size() < k) {
            throw new IllegalArgumentException();
        }
        return partitionIntoHelper(elts, Arrays.asList(new Partitioning<T>()), k, 0);
    }

    public static <T> List<Partitioning<T>> partitionIntoHelper(
            Queue<T> elts,
            List<Partitioning<T>> resultSoFar,
            int numEmptyParts,
            int numNonemptyParts) {
        throw new RuntimeException();
    }

    interface Box<T> {}

    interface Function<P, R> {
        R apply(P p);
    }

    interface Utils {
        <I, O> Box<O> foo(Box<I> input, Function<? super I, ? extends O> function);

        <I, O> Function<I, O> bar(Function<? super I, ? extends O> function);
    }

    class Test {
        Box<Integer> demo(Utils u, Box<String> bs) {
            return u.foo(bs, u.bar((String s) -> 5));
        }

        Integer ugh(String n) {
            return 5;
        }

        Box<Integer> demo2(Utils u, Box<String> bs) {
            return u.foo(bs, u.bar(this::ugh));
        }
    }

    abstract class Test2 {
        abstract <T> Box<Box<T>> foo(Box<? extends Box<? extends T>> p);

        abstract <T> Box<Box<T>> bar(Function<Number, T> f);

        abstract String baz(Number p);

        Box<Box<String>> demo() {
            return foo(bar(this::baz));
        }
    }
}