collapse statement lambda to expression lambda: enable for value compatible lambdas (IDEA-122785)

This commit is contained in:
Anna Kozlova
2014-03-24 17:22:16 +01:00
parent b19b34af63
commit aa6dbcd24a
3 changed files with 10 additions and 7 deletions

View File

@@ -95,12 +95,7 @@ public class RedundantLambdaCodeBlockInspection extends BaseJavaBatchLocalInspec
return returnStatement.getReturnValue();
}
else {
final PsiExpression expression = ((PsiExpressionStatement)statements[0]).getExpression();
final PsiType psiType = expression.getType();
if (psiType != PsiType.VOID) {
return null;
}
return expression;
return ((PsiExpressionStatement)statements[0]).getExpression();
}
}
}

View File

@@ -0,0 +1,8 @@
// "Replace with expression lambda" "true"
class Test {
{
Runnable c = () -> foo();
}
int foo() {return 1;}
}

View File

@@ -1,4 +1,4 @@
// "Replace with expression lambda" "false"
// "Replace with expression lambda" "true"
class Test {
{
Runnable c = () -> <caret>{foo();};