Files
openide/java/java-tests/testData/inspection/java9CollectionFactory/beforeUnknownNullability.java
Tagir Valeev d2320c01cc [java-inspections] Java9CollectionFactoryInspection: more conservative null handling (IDEA-294007)
GitOrigin-RevId: 1395d30a1df4e2dc9533254d5aa38737178dcca8
2022-05-17 08:48:50 +00:00

22 lines
603 B
Java

// "Fix all 'Immutable collection creation can be replaced with collection factory call' problems in file" "true"
import java.util.*;
class Main {
void nothingInterestingHere() {
System.out.println(of(null, null));
}
public <K, V> Map<K, V> of(K k1, V v1) {
Objects.requireNonNull(k1);
Objects.requireNonNull(v1);
Map<K, V> map = new HashMap<>(1);
map.put(k1, v1);
return Collections.<caret>unmodifiableMap(map);
}
public <K, V> Map<K, V> of1(K k1, V v1) {
Map<K, V> map = new HashMap<>(1);
map.put(k1, v1);
return Collections.unmodifiableMap(map);
}
}