mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
inference variables: ensure variable is not mixed with type parameter for recursive calls (IDEA-147639)
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
private <S> List<S> bar(List<S> list) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private <E> List<List<E>> foo(List<E> l) {
|
||||
foo(bar(l));
|
||||
final List<List<Object>> perms = foo(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <E> List<E> pipe(E head, List<E> tail) {
|
||||
List<E> newList = new ArrayList<>(tail);
|
||||
newList.add(0, head);
|
||||
return newList;
|
||||
}
|
||||
public static <E> List<E> subtract(List<E> list, E e) {
|
||||
List<E> newList = new ArrayList<>(list);
|
||||
newList.remove(e);
|
||||
return newList;
|
||||
}
|
||||
public static <E> List<List<E>> perms(List<E> l) {
|
||||
return l.isEmpty()
|
||||
? Collections.singletonList(Collections.emptyList())
|
||||
: l.stream().flatMap(h -> perms(subtract(l, h)).stream()
|
||||
.map(t -> pipe(h, t))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(perms(Arrays.asList("a", "b", "c")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user