new inference: ignore return dependencies of a variable when proper bound is present (IDEA-119535)

This commit is contained in:
Anna Kozlova
2014-03-13 19:30:34 +01:00
parent 766bdc0151
commit 219506dabf
4 changed files with 126 additions and 1 deletions
@@ -1,3 +1,4 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -5,6 +6,8 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
import static java.util.stream.Collectors.*;
class Stuff {
public enum Type { A }
private final int value;
@@ -41,4 +44,31 @@ class FakeErrors {
Collector<? super T, A, D> downstream) {
return null;
}
}
class FakeErrorsComplete {
public static List<Stuff> elems(){
return Arrays.asList(
new Stuff(800, Stuff.Type.A));
}
public static void main(String ... args){
Map<Stuff.Type, Optional<Stuff>> bar =
elems()
.stream()
.collect(groupingBy(Stuff::getType,
reducing((d1, d2) -> d1.getValue() > d2.getValue() ? d1 : d2)));
System.out.println(bar);
Map<Stuff.Type, Stuff> baz =
elems()
.stream()
.collect(groupingBy(Stuff::getType,
collectingAndThen(reducing((Stuff d1, Stuff d2) -> d1.getValue() > d2.getValue() ? d1 : d2),
Optional::get)));
System.out.println(baz);
}
}