File: Bug7.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 (39 lines) | stat: -rw-r--r-- 1,192 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
package inference.guava;

import java.io.Serializable;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collector;

@SuppressWarnings("") // Just check for crashes.
public class Bug7 {
    static <T, K, V> Collector<T, ?, MyMap<K, V>> toMap(
            Function<? super T, ? extends K> keyFunction,
            Function<? super T, ? extends V> valueFunction) {
        return Collector.of(
                MyMap.Builder<K, V>::new,
                (builder, input) ->
                        builder.put(keyFunction.apply(input), valueFunction.apply(input)),
                MyMap.Builder::combine,
                MyMap.Builder::build);
    }

    public abstract static class MyMap<K, V> implements Map<K, V>, Serializable {
        public static class Builder<K, V> {

            public Builder() {}

            public Builder<K, V> put(K key, V value) {
                throw new RuntimeException();
            }

            Builder<K, V> combine(Builder<K, V> other) {
                throw new RuntimeException();
            }

            public MyMap<K, V> build() {
                throw new RuntimeException();
            }
        }
    }
}