IDEA-200455 Suggest to replace (a, b) -> a + b lambdas with Integer::sum, Long::sum, Double::sum

This commit is contained in:
Tagir Valeev
2019-01-31 14:20:20 +07:00
parent cde7d6a7ff
commit 8da8dca8e0
14 changed files with 95 additions and 13 deletions

View File

@@ -0,0 +1,8 @@
// "Replace lambda with method reference" "true"
import java.util.function.IntBinaryOperator;
class Bar {
public void test(Object obj) {
IntBinaryOperator op = Integer::sum;
}
}

View File

@@ -0,0 +1,10 @@
// "Replace lambda with method reference" "true"
class Bar {
interface Foo {
int sum(Byte b1, Byte b2);
}
public void test(Object obj) {
Foo foo = Integer::sum;
}
}

View File

@@ -0,0 +1,8 @@
// "Replace lambda with method reference" "true"
import java.util.function.LongBinaryOperator;
class Bar {
public void test(Object obj) {
LongBinaryOperator op = Long::sum;
}
}

View File

@@ -0,0 +1,8 @@
// "Replace lambda with method reference" "true"
import java.util.function.IntBinaryOperator;
class Bar {
public void test(Object obj) {
IntBinaryOperator op = (a, b) -> (a) + <caret>b;
}
}

View File

@@ -0,0 +1,10 @@
// "Replace lambda with method reference" "true"
class Bar {
interface Foo {
int sum(Byte b1, Byte b2);
}
public void test(Object obj) {
Foo foo = (b1, b2) -> b1<caret> + b2;
}
}

View File

@@ -0,0 +1,8 @@
// "Replace lambda with method reference" "true"
import java.util.function.LongBinaryOperator;
class Bar {
public void test(Object obj) {
LongBinaryOperator op = (a, b) -> b + <caret>a;
}
}