redundant casts: don't treat cast as redundant if functional expression get more specific type (IDEA-152093)

This commit is contained in:
Anna Kozlova
2016-02-24 21:05:13 +01:00
parent e9b71e842b
commit 6e9234b115
5 changed files with 23 additions and 20 deletions
@@ -20,7 +20,7 @@ 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 -> {});
strings.forEach((IFunction<String>) arg -> {});
strings.forEach((IIFunction<String>) arg -> {});
}
}
@@ -15,6 +15,6 @@ class Test {
{
Predicate<String> mh2 = (SerPredicate<String>)Test::test;
Predicate<String> mh02 = (<warning descr="Casting 'Test::test' to 'NonSerPredicate<String>' is redundant">NonSerPredicate<String></warning>)Test::test;
Predicate<String> mh02 = (NonSerPredicate<String>)Test::test;
}
}
@@ -6,7 +6,7 @@ class Test {
public static void main(String[] args) {
Runnable r = (Runnable & Serializable) (() -> {});
r = (Runnable & Serializable)() -> {};
r = (<warning descr="Casting '() -> {}' to 'Runnable & I' is redundant">Runnable & I</warning>)() -> {};
r = (Runnable & I)() -> {};
System.out.println(r);
}