IDEA-160778 Buggy replacement with collect when several variables are declared in the same statement

This commit is contained in:
Tagir Valeev
2016-09-06 12:08:23 +07:00
parent f0276b724d
commit 7214316544
3 changed files with 51 additions and 12 deletions
@@ -0,0 +1,16 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Collect {
class Person {
String getName() {
return "";
}
}
void collectNames(List<Person> persons){
List<String> names = new ArrayList<>(), otherNames = new ArrayList<>(names);
names.addAll(persons.stream().map(Person::getName).collect(Collectors.toList()));
}
}
@@ -0,0 +1,17 @@
// "Replace with collect" "true"
import java.util.*;
public class Collect {
class Person {
String getName() {
return "";
}
}
void collectNames(List<Person> persons){
List<String> names = new ArrayList<>(), otherNames = new ArrayList<>(names);
for (Person person : pers<caret>ons) {
names.add(person.getName());
}
}
}