mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
lambda highlighting: if return statement has problem, try to highlight only corresponding return even if containing inference failed
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ class TypeArgsConsistency1 {
|
||||
I<Integer> i1 = (i, j) -> i + j;
|
||||
foo((i, j) -> i + j);
|
||||
I<Integer> i2 =bar((i, j) -> i) ;
|
||||
I<Integer> i3 = bar(<error descr="Bad return type in lambda expression: String cannot be converted to int">(i, j) -> "" + i + j</error>);
|
||||
I<Integer> i3 = bar((i, j) -> <error descr="Bad return type in lambda expression: String cannot be converted to int">"" + i + j</error>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -66,9 +66,9 @@ class Test2 {
|
||||
{
|
||||
bar(x -> x);
|
||||
bar1(x -> x);
|
||||
bar2(1, <error descr="Bad return type in lambda expression: List<Integer> cannot be converted to Integer">x -> x</error>);
|
||||
bar2("", <error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x -> x</error>);
|
||||
bar3(<error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x -> x</error>, "");
|
||||
bar2(1, x -> <error descr="Bad return type in lambda expression: List<Integer> cannot be converted to Integer">x</error>);
|
||||
bar2("", x -> <error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x</error>);
|
||||
bar3(x -> <error descr="Bad return type in lambda expression: List<String> cannot be converted to String">x</error>, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user