lambda: missed ground type for target functional type (IDEA-149053)

This commit is contained in:
Anna Kozlova
2015-12-09 21:16:45 +01:00
parent 9697949fe1
commit 7249fd8179
3 changed files with 21 additions and 1 deletions

View File

@@ -1287,7 +1287,8 @@ public class InferenceSession {
if (formula instanceof ExpressionCompatibilityConstraint) {
PsiExpression expression = ((ExpressionCompatibilityConstraint)formula).getExpression();
if (expression instanceof PsiLambdaExpression) {
PsiType parameterType = ((ExpressionCompatibilityConstraint)formula).getT();
PsiType parameterType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(((ExpressionCompatibilityConstraint)formula).getT(),
(PsiLambdaExpression)expression);
collectLambdaReturnExpression(additionalConstraints, (PsiLambdaExpression)expression, parameterType, !isProperType(parameterType), substitutor);
}
}

View File

@@ -0,0 +1,15 @@
interface I<T, R> {
R m(T t);
}
abstract class A<B> {
public abstract A<B> bar(I<Throwable, ? extends A<? extends B>> resumeFunction);
void foo(A<?> a) {
a.bar(throwable -> A.error());
}
public static final <T> A<T> error() {
return null;
}
}

View File

@@ -244,6 +244,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testGroundTargetTypeForExpectedReturnTypeOfLambdaExpression() throws Exception {
doTest();
}
private void doTest() {
doTest(false);
}