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:
Pavel Dolgov
2016-06-24 14:00:51 +03:00
parent aa7feafa82
commit 5e380e7526
24 changed files with 185 additions and 84 deletions
@@ -0,0 +1,6 @@
// "Remove redundant types" "true"
class Test {
{
Comparable<String> r = (St<caret>ring o) -> 1;
}
}
@@ -0,0 +1,6 @@
// "Remove redundant types" "false"
class Test {
{
Runnable r = (<caret>) -> {};
}
}
@@ -0,0 +1,6 @@
// "Remove redundant types" "false"
class Test {
{
Comparable<String> r = <caret>o -> 1;
}
}
@@ -0,0 +1,6 @@
// "Remove redundant types" "true"
class Test {
{
Comparable<String> r = o -> 1;
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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) -> "");
}
}
@@ -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 -> "");
}
}
@@ -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) -> {});
}
}
@@ -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);
}
}