redundant cast: don't warn if functional expression corresponds to another interface method (IDEA-140218)

This commit is contained in:
Anna Kozlova
2015-05-13 14:39:06 +02:00
parent 5b175a09bc
commit ad840dea8a
3 changed files with 39 additions and 3 deletions
@@ -0,0 +1,26 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
interface IoFunction<T> extends Consumer<T> {
@Override
default void accept(T t) {}
void acceptX(T t) throws IOException;
}
interface IFunction<T> extends Consumer<T> {
void accept(T t);
}
interface IIFunction<T> extends Consumer<T> {}
class Test {
public static void main(String[] args) {
List<String> strings = Arrays.asList("a", "b", "c");
strings.forEach((IoFunction<String>) arg -> {throw new IOException();});
strings.forEach((<warning descr="Casting 'arg -> {}' to 'IFunction<String>' is redundant">IFunction<String></warning>) arg -> {});
strings.forEach((<warning descr="Casting 'arg -> {}' to 'IIFunction<String>' is redundant">IIFunction<String></warning>) arg -> {});
}
}