Files
Mikhail Pyltsinandintellij-monorepo-bot 44d8141180 [java-inspections] IDEA-328272 "Replace 'if' with 'switch'" inspection generating code incorrectly
- not call twice if variable is initialized with method calls
- use references to variable in default branch only if it is definite assignment

GitOrigin-RevId: bfe7af32d011c4ec275930770578527f23770057
2023-08-28 14:08:05 +00:00

14 lines
264 B
Java

// "Replace with 'switch' expression" "false"
class NotDefenitelyAssignment1 {
void test(int x) {
String s;
if (Math.random() > 0.5) {
s = "bar";
}
swi<caret>tch (x) {
case 1:s = "baz";break;
case 2:s = "qux";break;
}
}
}