IDEA-209947 Explain &&/||-chains, minor fixes

GitOrigin-RevId: 074ea99bdc28c9f026e097ee5630c3a8c0614dd6
This commit is contained in:
Tagir Valeev
2019-04-28 17:44:51 +03:00
committed by intellij-monorepo-bot
parent 3368f8e2d5
commit 0eacb8621a
7 changed files with 110 additions and 4 deletions
@@ -0,0 +1,13 @@
/*
Value is always false (x > 6 && y > 10)
Operand #1 of &&-chain is false (x > 6)
Left operand is 5 (x)
'x' was assigned (5)
*/
class Test {
void test(int y) {
int x = 5;
if(<selection>x > 6 && y > 10</selection>) {}
}
}
@@ -0,0 +1,17 @@
/*
Value is always false (a > 5 && b < 0 && b > a)
One of the following happens:
Operand #1 of &&-chain is false (a > 5)
Operand #2 of &&-chain is false (b < 0)
Operand #3 of &&-chain is false (b > a)
Left operand is <= -1 (b)
Range is known from line #15 (b < 0)
Right operand is >= 6 (a)
Range is known from line #15 (a > 5)
*/
class Test {
void test(int a, int b) {
if(<selection>a > 5 && b < 0 && b > a</selection>) {}
}
}
@@ -0,0 +1,11 @@
/*
Value is always true (b)
'b' was assigned (true)
*/
class Test {
void test() {
boolean b = true;
if(<selection>b</selection>) {}
}
}
@@ -0,0 +1,24 @@
/*
Value is always true (x || (a+b)+(c+d)==10)
One of the following happens:
Operand #1 of ||-chain is true (x)
Operand #2 of ||-chain is true ((a+b)+(c+d)==10)
Result of '+' is 10 ((a+b)+(c+d))
Result of '+' is 3 (a+b)
Left operand is 1 (a)
'a' was assigned (1)
Right operand is 2 (b)
'b' was assigned (2)
Result of '+' is 7 (c+d)
Left operand is 3 (c)
'c' was assigned (3)
Right operand is 4 (d)
'd' was assigned (4)
*/
class Test {
void test(boolean x) {
int a = 1, b = 2, c = 3, d = 4;
if(<selection>x || (a+b)+(c+d)==10</selection>) {}
}
}