IfStatementWithIdenticalBranchesInspection: more correct variable substitution : IDEA-229916

GitOrigin-RevId: b8abb67866823a84dac2b3dc4070e088926e0527
This commit is contained in:
Roman.Ivanov
2020-01-09 13:52:17 +07:00
committed by intellij-monorepo-bot
parent 2bcc2a5a13
commit fa9c908137
2 changed files with 24 additions and 5 deletions

View File

@@ -0,0 +1,18 @@
// "Collapse 'if' statement" "false"
public class Main {
// https://youtrack.jetbrains.com/issue/IDEA-229916
public void analysisBugWithMinAndMax(int width, int height, boolean someFlag) {
if<caret> (someFlag) {
int a = Math.max(width, height);
int b = Math.min(width, height);
System.out.println("a=" + a + ", b=" + b);
}
else {
int b = Math.max(width, height);
int a = Math.min(width, height);
System.out.println("a=" + a + ", b=" + b);
}
}
}