FunctionHelper: fix renaming in lambdas if autogenerated name conflicts with the existing one

This commit is contained in:
Tagir Valeev
2016-12-16 11:12:15 +07:00
parent cda8154dbc
commit 9c78db8af0
3 changed files with 60 additions and 15 deletions
@@ -0,0 +1,24 @@
// "Replace Stream API chain with loop" "true"
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class Main {
public List<? extends CharSequence> getList() {
return Collections.emptyList();
}
private void collect() {
List<CharSequence> list = new ArrayList<>();
for (CharSequence charSequence : getList()) {
if (Objects.nonNull(charSequence)) {
list.add(charSequence);
}
}
List<? extends CharSequence> res = list;
System.out.println(res);
}
}
@@ -0,0 +1,17 @@
// "Replace Stream API chain with loop" "true"
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class Main {
public List<? extends CharSequence> getList() {
return Collections.emptyList();
}
private void collect() {
List<? extends CharSequence> res = getList().stream().filter(Objects::nonNull).col<caret>lect(Collectors.toList());
System.out.println(res);
}
}