mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
[java]: redundant cast: treat switch expression branches separately (IDEA-269929)
GitOrigin-RevId: 4eecfab7aff32bc69164b740d1bd36f9a29b6cda
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5a42eae302
commit
890efeaded
@@ -1,4 +1,5 @@
|
||||
import java.util.function.Predicate;
|
||||
import java.util.*;
|
||||
|
||||
class RedundantCast {
|
||||
private static void foo(final int matchType) {
|
||||
@@ -14,4 +15,20 @@ class RedundantCast {
|
||||
yield (<warning descr="Casting 'target -> {...}' to 'Predicate<Object>' is redundant">Predicate<Object></warning>) target -> target == null;
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
<T> List<T> getList1(int x) {
|
||||
return (List<T>) switch(x) {
|
||||
case 0 -> new ArrayList<>();
|
||||
default -> new ArrayList<Integer>();
|
||||
};
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
<T> List<T> getList2(int x) {
|
||||
return (<warning descr="Casting 'switch(x) { ...' to 'List<T>' is redundant">List<T></warning>) switch(x) {
|
||||
case 0 -> new ArrayList<>();
|
||||
default -> new ArrayList<>();
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user