IDEA-55556 Inspection suggestion: Comparison that is always false due to being out of type range on implicit type conversion

This commit is contained in:
peter
2014-04-18 22:37:32 +02:00
parent 996d0c6a63
commit 3af306c66e
5 changed files with 85 additions and 148 deletions
@@ -0,0 +1,19 @@
class Foo {
private void foo(byte myByte) {
if (<warning descr="Condition 'myByte == 0xFF' is always 'false'">myByte == 0xFF</warning>) {
System.out.println("wrong");
}
if (<warning descr="Condition 'myByte != 0xFFF' is always 'true'">myByte != 0xFFF</warning>) {
System.out.println("wrong");
}
if (myByte == (byte) 0xFF) {
System.out.println("right");
}
}
void foo2(int i) {
boolean a = <warning descr="Condition 'i < 0x80000000L' is always 'true'">i < 0x80000000L</warning>;
boolean f = <warning descr="Condition 'i > 0x7fffffff' is always 'false'">i > 0x7fffffff</warning>;
}
}