redundant return type: method reference/expr lambda with void SAM

global inspection, IDEA-189010
This commit is contained in:
Anna.Kozlova
2018-03-28 13:36:37 +02:00
parent b50b64b11f
commit 5b2cc36825

View File

@@ -236,7 +236,8 @@ public class RefJavaUtilImpl extends RefJavaUtil{
if (refExpression instanceof PsiMethodReferenceExpression) {
PsiType returnType = psiMethod.getReturnType();
if (!psiMethod.isConstructor() && !PsiType.VOID.equals(returnType)) {
if (!psiMethod.isConstructor() &&
!PsiType.VOID.equals(LambdaUtil.getFunctionalInterfaceReturnType((PsiFunctionalExpression)refExpression))) {
refMethod.setReturnValueUsed(true);
addTypeReference(psiFrom, returnType, refFrom.getRefManager());
}
@@ -257,7 +258,9 @@ public class RefJavaUtilImpl extends RefJavaUtil{
if (call != null) {
PsiType returnType = psiMethod.getReturnType();
if (!psiMethod.isConstructor() && !PsiType.VOID.equals(returnType)) {
if (!(call.getParent() instanceof PsiExpressionStatement)) {
PsiElement parent = call.getParent();
if (!(parent instanceof PsiExpressionStatement) &&
!(parent instanceof PsiLambdaExpression && PsiType.VOID.equals(LambdaUtil.getFunctionalInterfaceReturnType((PsiFunctionalExpression)parent)))) {
refMethod.setReturnValueUsed(true);
}