mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
a test for IDEA-98211 "Constant conditions & exceptions": warning about possible ClassCastException is shown in one case, but one in another similar one
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import java.util.Date;
|
||||
|
||||
public class DataFlowBug {
|
||||
|
||||
private static boolean isNumberable(Object o) {
|
||||
return o instanceof Number;
|
||||
}
|
||||
|
||||
public Object add(Object left, Object right) {
|
||||
if (left != null && right != null && (left instanceof Date || right instanceof Date)) {
|
||||
if (isNumberable(left)) {
|
||||
return ((<warning descr="Casting 'right' to 'Date' may produce 'java.lang.ClassCastException'">Date</warning>) right).getTime();
|
||||
}
|
||||
|
||||
if (isNumberable(right)) {
|
||||
return ((<warning descr="Casting 'left' to 'Date' may produce 'java.lang.ClassCastException'">Date</warning>) left).getTime();
|
||||
}
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user