dfa: suppress constant condition checking for expression-internal assignments (IDEA-31697)

This commit is contained in:
peter
2015-07-10 20:38:53 +02:00
parent d49de05320
commit 1155a92a9e
7 changed files with 32 additions and 13 deletions
@@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -1,6 +0,0 @@
public class NonconstantCondition {
void test(boolean flag) {
if (flag == (flag = true)) {
}
}
}
@@ -0,0 +1,16 @@
class Contracts {
void test(boolean flag) {
if (flag == (flag = true)) System.out.println();
int x = 1;
boolean y = x == (x +=1); // returns false
if (y) System.out.println();
int k = 1;
boolean z = (k +=1) == k; // returns true
if (z) System.out.println();
}
}