mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
Java inspection: convert the intention for "Remove redundant lambda parameter types" into an INFORMATION-level inspection (IDEA-156028, IDEA-157727)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
// "Remove redundant types" "true"
|
||||
class Test {
|
||||
{
|
||||
Comparable<String> r = (St<caret>ring o) -> 1;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Remove redundant types" "false"
|
||||
class Test {
|
||||
{
|
||||
Runnable r = (<caret>) -> {};
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Remove redundant types" "false"
|
||||
class Test {
|
||||
{
|
||||
Comparable<String> r = <caret>o -> 1;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Remove redundant types" "true"
|
||||
class Test {
|
||||
{
|
||||
Comparable<String> r = o -> 1;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Remove redundant types" "false"
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
<K> void f(Function<K, String>... l){}
|
||||
|
||||
{
|
||||
f(null, (Str<caret>ing s) -> s);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Remove redundant types" "false"
|
||||
class Test2 {
|
||||
class Y<T>{
|
||||
T t;
|
||||
}
|
||||
|
||||
interface I<X> {
|
||||
X foo(Y<X> list);
|
||||
}
|
||||
|
||||
static <T> I<T> bar(I<T> i){return i;}
|
||||
|
||||
{
|
||||
Test2.bar((Y<St<caret>ring> y) -> y.t);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Remove redundant types" "false"
|
||||
class NoInferenceResult {
|
||||
interface I<A, B> {
|
||||
B foo(A a);
|
||||
}
|
||||
|
||||
<A, B> I<A, B> m(I<A, B> f) { return null; }
|
||||
|
||||
void test() {
|
||||
m((Stri<caret>ng s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Remove redundant types" "true"
|
||||
class Test2 {
|
||||
class Y<T>{
|
||||
T t;
|
||||
}
|
||||
|
||||
interface I<X> {
|
||||
X foo(Y<X> list);
|
||||
}
|
||||
|
||||
static <T> I<T> bar(I<T> i){return i;}
|
||||
|
||||
{
|
||||
Test2.<String>bar((Y<St<caret>ring> y) -> y.t);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Remove redundant types" "true"
|
||||
class Test2 {
|
||||
class Y<T>{
|
||||
T t;
|
||||
}
|
||||
|
||||
interface I<X> {
|
||||
X foo(Y<X> list);
|
||||
}
|
||||
|
||||
static <T> I<T> bar(I<T> i){return i;}
|
||||
|
||||
{
|
||||
Test2.<String>bar(y -> y.t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class InChain {
|
||||
public static void main(String[] args) {
|
||||
Stream.of("a").map((String<caret> s) -> s + "1").forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class InChain {
|
||||
public static void main(String[] args) {
|
||||
Stream.of("a").map(s -> s + "1").forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Remove redundant types" "true"
|
||||
class ReturnTypeCompatibility {
|
||||
|
||||
interface I1<L> {
|
||||
L m(L x);
|
||||
}
|
||||
|
||||
static <P> void call(P p, I1<P> i2) {
|
||||
i2.m(null);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
call("", (Str<caret>ing i) -> "");
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Remove redundant types" "true"
|
||||
class ReturnTypeCompatibility {
|
||||
|
||||
interface I1<L> {
|
||||
L m(L x);
|
||||
}
|
||||
|
||||
static <P> void call(P p, I1<P> i2) {
|
||||
i2.m(null);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
call("", i -> "");
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Remove redundant types" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
foo.forEach((Str<caret>ing s) -> {});
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Remove redundant types" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
foo.forEach(s -> {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Remove redundant types" "false"
|
||||
class Test3 {
|
||||
interface I<Y> {
|
||||
void m(Y y);
|
||||
}
|
||||
|
||||
static <T> void bar(I<T> i, List<T> l){
|
||||
bar((<caret>T x) -> {}, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user