mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
ControlFlowUtil#isVariableAssignedInLoop: evaluate constant conditions
Fixes IDEA-186306 good code red: variable might be assigned in loop
This commit is contained in:
+19
@@ -111,4 +111,23 @@ class T3a {
|
||||
<error descr="Variable 'b' might already have been assigned to">b</error> = true; // red
|
||||
System.out.println(b);
|
||||
}
|
||||
}
|
||||
class T29 {
|
||||
// IDEA-186306
|
||||
private final int j;
|
||||
T29 (int b) {
|
||||
do {
|
||||
j = 34; // guaranteed to only be executed once
|
||||
if (true) break;
|
||||
} while (b == 1);
|
||||
}
|
||||
}
|
||||
class T29a {
|
||||
private final int j;
|
||||
T29a (int b) {
|
||||
do {
|
||||
<error descr="Variable 'j' might be assigned in loop">j</error> = 34; // not guaranteed by JLS to only be executed once
|
||||
if (j > 0) break;
|
||||
} while (b == 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user