inference: skip standalone expressions in lambda returns (IDEA-171922)

This commit is contained in:
Anna.Kozlova
2017-04-26 16:28:04 +02:00
parent 914bdb0ab9
commit fbf500d2d4
3 changed files with 18 additions and 0 deletions
@@ -129,6 +129,9 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm
PsiExpression expression,
PsiType targetType,
boolean registerErrorOnFailure) {
if (!PsiPolyExpressionUtil.isPolyExpression(expression)) {
return session;
}
final PsiExpressionList argumentList = ((PsiCall)expression).getArgumentList();
if (argumentList != null) {
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argumentList);
@@ -0,0 +1,14 @@
import java.util.ArrayList;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
class Foo {
private static void foo(final Function<String, ?> compose) {
Collector<String, ?, ? extends Map<?, ArrayList<String>>> stringMapCollector =
Collectors.groupingBy(compose, Collector.of(() -> new ArrayList<String>(), null, null, s -> new ArrayList<>(s)));
}
}
@@ -155,6 +155,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testGroundTargetTypeWhenAbstractMethodInSuperclass() { doTest(); }
public void testNestedLambdasWithInferenceOfReturnTypeInTheLatestLambda() { doTest(); }
public void testCapturedWildcardNotOpenedDuringInference() { doTest(); }
public void testIgnoreStandaloneExpressionsInLambdaReturnForNestedCalls() { doTest(); }
private void doTest() {
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());