Java: Intention that wraps list/set/map with Collections.unmodifiable - use results of DFA, test fixed (IDEA-93154)

This commit is contained in:
Pavel Dolgov
2019-02-25 17:55:54 +03:00
parent 5fed91a5ab
commit 564bb424de
10 changed files with 87 additions and 6 deletions
@@ -0,0 +1,11 @@
// "Wrap with unmodifiable list" "true"
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
class C {
List<List<String>> test() {
List<String> result = new ArrayList<>();
return List.of(Collections.unmodifiableList(result));
}
}
@@ -0,0 +1,13 @@
// "Wrap with unmodifiable map" "true"
import java.util.Collections;
import java.util.Map;
import java.util.HashMap;
class C {
void test() {
var result = new HashMap<>();
foo(Collections.unmodifiableMap(result));
}
void foo(Map<String, Integer> map) {}
}
@@ -0,0 +1,10 @@
// "Wrap with unmodifiable list" "false"
import java.util.List;
import java.util.Collections;
class C {
List<String> test() {
List<String> result = Collections.emptyList();
return <caret>result;
}
}
@@ -0,0 +1,10 @@
// "Wrap with unmodifiable list" "true"
import java.util.List;
import java.util.ArrayList;
class C {
List<List<String>> test() {
List<String> result = new ArrayList<>();
return List.of(re<caret>sult);
}
}
@@ -0,0 +1,10 @@
// "Wrap with unmodifiable list" "false"
import java.util.List;
import java.util.ArrayList;
class C {
List<List<String>> test() {
List<String> result = new ArrayList<>();
return List.<caret>of(result);
}
}
@@ -1,4 +1,4 @@
// "Wrap with unmodifiable map" "false"
// "Wrap with unmodifiable map" "true"
import java.util.Map;
import java.util.HashMap;
@@ -4,7 +4,7 @@ import java.util.ArrayList;
class C {
ArrayList<String> test() {
List<String> result = new ArrayList<>();
ArrayList<String> result = new ArrayList<>();
return <caret>result;
}
}
@@ -0,0 +1,9 @@
// "Wrap with unmodifiable set" "false"
import java.util.*;
class C {
Set<String> test() {
Set<String> result = Collections.unmodifiableSortedSet(new TreeSet<>());
return <caret>result;
}
}