| 1 |
// Test case for Issue 1948: |
| 2 |
// https://github.com/typetools/checker-framework/issues/1948 |
| 3 |
|
| 4 |
import java.util.Collection; |
| 5 |
import java.util.Map; |
| 6 |
import java.util.Set; |
| 7 |
import java.util.concurrent.ConcurrentMap; |
| 8 |
import java.util.function.BiConsumer; |
| 9 |
import java.util.function.BiFunction; |
| 10 |
import java.util.function.Function; |
| 11 |
|
| 12 |
@SuppressWarnings("") // ensure no crash |
| 13 |
class Issue1948<K, V, E extends Issue1948.MyEntry<K, V, E>, S extends Issue1948.MyClass<K, V, E, S>> |
| 14 |
implements ConcurrentMap<K, V> { |
| 15 |
|
| 16 |
private Issue1948(MapMaker builder, InternalEntryHelper<K, V, E, S> entryHelper) {} |
| 17 |
|
| 18 |
/** Returns a fresh {@link Issue1948} as specified by the given {@code builder}. */ |
| 19 |
static <K, V> Issue1948<K, V, ? extends MyEntry<K, V, ?>, ?> create(MapMaker builder) { |
| 20 |
return new Issue1948<>(builder, Helper.<K, V>instance()); |
| 21 |
} |
| 22 |
|
| 23 |
interface MyEntry<K, V, E extends MyEntry<K, V, E>> {} |
| 24 |
|
| 25 |
abstract static class MyClass< |
| 26 |
K, V, E extends MyEntry<K, V, E>, S extends MyClass<K, V, E, S>> {} |
| 27 |
|
| 28 |
static final class MapMaker {} |
| 29 |
|
| 30 |
static final class Helper<K, V> |
| 31 |
implements InternalEntryHelper< |
| 32 |
K, V, StrongKeyStrongValueEntry<K, V>, StrongKeyStrongValueMyClass<K, V>> { |
| 33 |
static <K, V> Helper<K, V> instance() { |
| 34 |
return null; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
interface InternalEntryHelper<K, V, E extends MyEntry<K, V, E>, S> {} |
| 39 |
|
| 40 |
abstract static class StrongKeyStrongValueEntry<K, V> |
| 41 |
extends AbstractStrongKeyEntry<K, V, StrongKeyStrongValueEntry<K, V>> |
| 42 |
implements StrongValueEntry<K, V, StrongKeyStrongValueEntry<K, V>> {} |
| 43 |
|
| 44 |
abstract static class AbstractStrongKeyEntry<K, V, E extends MyEntry<K, V, E>> |
| 45 |
implements MyEntry<K, V, E> {} |
| 46 |
|
| 47 |
interface StrongValueEntry<K, V, E extends MyEntry<K, V, E>> extends MyEntry<K, V, E> {} |
| 48 |
|
| 49 |
abstract static class StrongKeyStrongValueMyClass<K, V> |
| 50 |
extends MyClass< |
| 51 |
K, V, StrongKeyStrongValueEntry<K, V>, StrongKeyStrongValueMyClass<K, V>> {} |
| 52 |
|
| 53 |
@Override |
| 54 |
public int size() { |
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public boolean isEmpty() { |
| 60 |
return false; |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
public boolean containsKey(Object key) { |
| 65 |
return false; |
| 66 |
} |
| 67 |
|
| 68 |
@Override |
| 69 |
public boolean containsValue(Object value) { |
| 70 |
return false; |
| 71 |
} |
| 72 |
|
| 73 |
@Override |
| 74 |
public V get(Object key) { |
| 75 |
return null; |
| 76 |
} |
| 77 |
|
| 78 |
@Override |
| 79 |
public V put(K key, V value) { |
| 80 |
return null; |
| 81 |
} |
| 82 |
|
| 83 |
@Override |
| 84 |
public V remove(Object key) { |
| 85 |
return null; |
| 86 |
} |
| 87 |
|
| 88 |
@Override |
| 89 |
public void putAll(Map<? extends K, ? extends V> m) {} |
| 90 |
|
| 91 |
@Override |
| 92 |
public void clear() {} |
| 93 |
|
| 94 |
@Override |
| 95 |
public Set<K> keySet() { |
| 96 |
return null; |
| 97 |
} |
| 98 |
|
| 99 |
@Override |
| 100 |
public Collection<V> values() { |
| 101 |
return null; |
| 102 |
} |
| 103 |
|
| 104 |
@Override |
| 105 |
public Set<Entry<K, V>> entrySet() { |
| 106 |
return null; |
| 107 |
} |
| 108 |
|
| 109 |
@Override |
| 110 |
public V getOrDefault(Object key, V defaultValue) { |
| 111 |
return null; |
| 112 |
} |
| 113 |
|
| 114 |
@Override |
| 115 |
public void forEach(BiConsumer<? super K, ? super V> action) {} |
| 116 |
|
| 117 |
@Override |
| 118 |
public V putIfAbsent(K key, V value) { |
| 119 |
return null; |
| 120 |
} |
| 121 |
|
| 122 |
@Override |
| 123 |
public boolean remove(Object key, Object value) { |
| 124 |
return false; |
| 125 |
} |
| 126 |
|
| 127 |
@Override |
| 128 |
public boolean replace(K key, V oldValue, V newValue) { |
| 129 |
return false; |
| 130 |
} |
| 131 |
|
| 132 |
@Override |
| 133 |
public V replace(K key, V value) { |
| 134 |
return null; |
| 135 |
} |
| 136 |
|
| 137 |
@Override |
| 138 |
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {} |
| 139 |
|
| 140 |
@Override |
| 141 |
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { |
| 142 |
return null; |
| 143 |
} |
| 144 |
|
| 145 |
@Override |
| 146 |
public V computeIfPresent( |
| 147 |
K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { |
| 148 |
return null; |
| 149 |
} |
| 150 |
|
| 151 |
@Override |
| 152 |
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { |
| 153 |
return null; |
| 154 |
} |
| 155 |
|
| 156 |
@Override |
| 157 |
public V merge( |
| 158 |
K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) { |
| 159 |
return null; |
| 160 |
} |
| 161 |
} |