new inference: collect additional constraints from lambda return expressions when lambda parameters are already fixed; process constraints without input variables before others, so their 'return' expressions could influence next rounds; testdata (IDEA-144596)

This commit is contained in:
Anna Kozlova
2015-09-03 16:10:54 +03:00
parent 0ef6e3e118
commit 3893b9f6d4
4 changed files with 84 additions and 19 deletions

View File

@@ -0,0 +1,23 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class Test {
public void testIt()
{
Map<Integer, String> innerMap = new HashMap<>();
innerMap.put(2, "abc");
Map<Long, Map<Integer, String>> outerMap = new HashMap<>();
outerMap.put(1L, innerMap);
Map<Long, Map<Integer, String>> transformedMap = outerMap.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
m -> m.getValue().entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
v -> v.getValue().toUpperCase()))));
}
}

View File

@@ -0,0 +1,22 @@
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.Map;
import java.util.stream.Collector;
class FooBar {
void p(Map<String, String> m) {
m.entrySet().stream()
.collect(Collector.of(() -> new HashMap<>(),
(a, e) -> a.put(e.getValue(), e.getKey()),
(l, r) -> {
l.put<caret>All(r);
return l;
}));
}
}