new inference: stop collecting constraints if target type is proper (IDEA-136412)

This commit is contained in:
Anna Kozlova
2015-02-13 18:54:04 +01:00
parent 465879cacf
commit 853f9c567f
3 changed files with 20 additions and 1 deletions
@@ -308,7 +308,7 @@ public class InferenceSession {
if (calledMethod != null && PsiPolyExpressionUtil.isMethodCallPolyExpression(arg, calledMethod)) {
collectAdditionalConstraints(additionalConstraints, (PsiCallExpression)arg);
}
} else if (arg instanceof PsiLambdaExpression) {
} else if (arg instanceof PsiLambdaExpression && !isProperType(retrieveNonPrimitiveEqualsBounds(myInferenceVariables).substitute(parameterType))) {
collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)arg, parameterType);
}
}
@@ -0,0 +1,15 @@
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class Test {
private List<Map<String, String>> foo(Stream<Map.Entry<String, List<String>>> stream) {
return then(v -> stream.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toString())));
}
private <V> List<V> then(Function<Void, V> f) {
return null;
}
}
@@ -28,6 +28,10 @@ public class NewInferenceCollectingAdditionalConstraintsTest extends LightDaemon
doTest();
}
public void testStopCollectingAdditionalConstraintsWhenLambdaReturnTypeIsProper() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}