Files
openide/java/java-tests/testData/inspection/switchExpressionMigration/afterNotDefeniteAssignment.java
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
275 B
Java

// "Replace with enhanced 'switch' statement" "true-preview"
class NotDefenitessignment1 {
void test(int x) {
String s;
if (Math.random() > 0.5) {
s = "bar";
}
switch (x) {
case 1 -> s = "baz";
case 2 -> s = "qux";
}
}
}