Fix IDEA-177668 "Replace stream chain with loop" exception on unresolved collection type

This commit is contained in:
Tagir Valeev
2017-08-17 16:36:34 +07:00
parent 6305f35e72
commit 86874d0883
3 changed files with 20 additions and 1 deletions
@@ -113,6 +113,15 @@ public class Main {
return integers;
}
// Unresolved reference
void f(Collection<? extends Foo> c) {
R treeSet = new TreeSet();
for (Foo foo : c) {
treeSet.add(foo);
}
Set<Foo> uniqueDescriptors = treeSet;
}
public static void main(String[] args) {
new Main().testAveragingDouble("a", "bbb", null, "cc", "dd", "eedasfasdfs");
new Main().testAveragingInt("a", "bbb", null, "cc", "dd", "eedasfasdfs");
@@ -46,6 +46,12 @@ public class Main {
return IntStream.of(4, 2, 1).boxed().collect(Collectors.toCollection(TreeSet::new));
}
// Unresolved reference
void f(Collection<? extends Foo> c) {
Set<Foo> uniqueDescriptors = c.stream()
.collect(Collectors.toCollection(() -> new TreeSet()));
}
public static void main(String[] args) {
new Main().testAveragingDouble("a", "bbb", null, "cc", "dd", "eedasfasdfs");
new Main().testAveragingInt("a", "bbb", null, "cc", "dd", "eedasfasdfs");