Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/StreamToCollectionInlining.java
Tagir Valeev cf2a321abc [java-dfa] flushVariable: canonicalize before flush
Otherwise, we may try to remove variableType of wrong alias
Fixes IDEA-264644 toCollection(() -> list) is not recognized as mutation method for list

GitOrigin-RevId: ea9b87d3aed5fa187fd13565bd433af5c044d536
2021-03-19 05:48:20 +00:00

25 lines
625 B
Java

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class Main2 {
// IDEA-264644
void test() {
List<String> list = new ArrayList<>();
Stream.of("foo", "bar").collect(Collectors.toCollection(() -> list));
if (list.isEmpty()) {}
}
// IDEA-221210
public static void main(String[] args) {
List<Integer> originalList = new ArrayList<>();
originalList.add(1);
final List<Integer> newList = originalList.stream()
.collect(Collectors.toCollection(() -> new ArrayList<>(1)));
boolean empty = newList.isEmpty();
}
}