mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
lambda: relax incompatible return type in case of void functional types
This commit is contained in:
@@ -41,10 +41,10 @@ public class LambdaHighlightingUtil {
|
||||
if (body instanceof PsiCodeBlock) {
|
||||
if (!LambdaUtil.getReturnExpressions(lambdaExpression).isEmpty()) return "Unexpected return value";
|
||||
} else if (body instanceof PsiExpression) {
|
||||
final PsiType type = ((PsiExpression)body).getType();
|
||||
/*final PsiType type = ((PsiExpression)body).getType();
|
||||
if (type != PsiType.VOID) {
|
||||
return "Incompatible return type " + (type == PsiType.NULL || type == null ? "<null>" : type.getPresentableText()) +" in lambda expression";
|
||||
}
|
||||
}*/
|
||||
}
|
||||
} else if (functionalInterfaceReturnType != null) {
|
||||
final List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions(lambdaExpression);
|
||||
|
||||
@@ -7,7 +7,7 @@ class Test1 {
|
||||
VoidReturnType aI = () -> System.out.println();
|
||||
VoidReturnType aI1 = () -> {System.out.println();};
|
||||
VoidReturnType aI2 = <error descr="Unexpected return value">() -> {return 1;}</error>;
|
||||
VoidReturnType aI3 = <error descr="Incompatible return type int in lambda expression">() -> 1</error>;
|
||||
VoidReturnType aI3 = () -> 1;
|
||||
VoidReturnType aI4 = () -> {return;};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Test5 {
|
||||
static <T> void bar(I<T> i){}
|
||||
|
||||
{
|
||||
bar(<error descr="Incompatible return type <null> in lambda expression">() -> null</error>);
|
||||
bar(<error descr="Incompatible parameter types in lambda expression">() -> null</error>);
|
||||
}
|
||||
}
|
||||
class Test6 {
|
||||
@@ -31,7 +31,7 @@ class Test6 {
|
||||
static <T> void bar(I<T> i){}
|
||||
|
||||
{
|
||||
bar(<error descr="Incompatible return type <null> in lambda expression">() -> null</error>);
|
||||
bar(() -> null);
|
||||
bar(() -> {});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user