clear error message (IDEA-154419)

This commit is contained in:
Anna.Kozlova
2016-04-08 18:06:20 +02:00
parent a8ad27f8a9
commit 9150e6fd4a
2 changed files with 4 additions and 1 deletions

View File

@@ -641,6 +641,9 @@ public class LambdaUtil {
final PsiType type = ((PsiExpression)body).getType();
try {
if (!PsiUtil.isStatement(JavaPsiFacade.getElementFactory(body.getProject()).createStatementFromText(body.getText(), body))) {
if (PsiType.VOID.equals(type)) {
return "Lambda body must be a statement expression";
}
return "Bad return type in lambda expression: " + (type == PsiType.NULL || type == null ? "<null>" : type.getPresentableText()) + " cannot be converted to void";
}
}

View File

@@ -12,7 +12,7 @@ public class Main {
I<Integer> i1 = i -> <error descr="Bad return type in lambda expression: int cannot be converted to void">i * 2</error>;
I<Integer> i2 = i -> <error descr="Bad return type in lambda expression: int cannot be converted to void">2 * i</error>;
I<Integer> i3 = i -> <error descr="Bad return type in lambda expression: void cannot be converted to void">true ? foo() : foo()</error>;
I<Integer> i3 = i -> <error descr="Lambda body must be a statement expression">true ? foo() : foo()</error>;
}
}