mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
redundant lambda code block: do not suggest for expressions with non-void type
This commit is contained in:
@@ -97,7 +97,12 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaLocalInspectionT
|
||||
return returnStatement.getReturnValue();
|
||||
}
|
||||
else {
|
||||
return ((PsiExpressionStatement)statements[0]).getExpression();
|
||||
final PsiExpression expression = ((PsiExpressionStatement)statements[0]).getExpression();
|
||||
final PsiType psiType = expression.getType();
|
||||
if (psiType != PsiType.VOID) {
|
||||
return null;
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Replace with one line expression" "false"
|
||||
class Test {
|
||||
{
|
||||
Runnable c = () -> <caret>{foo();};
|
||||
}
|
||||
|
||||
int foo() {return 1;}
|
||||
}
|
||||
Reference in New Issue
Block a user