lambda highlighting: if return statement has problem, try to highlight only corresponding return even if containing inference failed

This commit is contained in:
Anna.Kozlova
2016-10-07 13:55:01 +02:00
parent c0de6f3d36
commit b560ee5910
5 changed files with 68 additions and 69 deletions
@@ -1,4 +1,5 @@
import java.util.Collections;
import java.util.List;
import java.util.function.Supplier;
class Test {
@@ -12,4 +13,14 @@ class Test {
}
public static void foo(Supplier<String> consumer) {}
private void foo(List<String> descriptions) {
Collections.sort(descriptions, (o1, o2) -> {
final int elementsDiff = o1.length() - o2.length();
if (elementsDiff == 0) {
return <error descr="Bad return type in lambda expression: boolean cannot be converted to int">o1.equals(o2)</error>;
}
return -elementsDiff;
});
}
}
@@ -13,7 +13,7 @@ class Test {
}
void bar(C c) {
foo(c, <error descr="Bad return type in lambda expression: A cannot be converted to C">x -> x.f()</error>);
foo(c, x -> <error descr="Bad return type in lambda expression: A cannot be converted to C">x.f()</error>);
foo(c, x -> x);
}