lambda expression isCongruent: ensure target function type has no type parameters

This commit is contained in:
Anna Kozlova
2015-02-01 12:54:19 +03:00
parent 6eabf8e78a
commit dbdc890cd1
3 changed files with 26 additions and 3 deletions
@@ -177,9 +177,6 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
}
final PsiExpressionList argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
if (candidateProperties != null) {
@@ -194,6 +191,7 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
}
}
leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
if (!isPotentiallyCompatible(leftType)) {
return false;
}
@@ -202,9 +200,12 @@ public class PsiLambdaExpressionImpl extends ExpressionPsiElement implements Psi
return true;
}
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
if (interfaceMethod == null) return false;
if (interfaceMethod.hasTypeParameters()) return false;
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);
if (hasFormalParameterTypes()) {