Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/liftThrowOutOfSwitchExpression/afterSwitchInsideBinaryExpressionInsideSwitchLabeledRuleWithoutBlock.java
Marcin Mikosik 9fd6ada970 [java] IDEA-283208 Add quickfix: Lift 'throw' out of 'switch' expression
Adds a quick-fix: "Lift 'throw' out of 'switch' expression" that that is provided for error "'switch' expression does not have any result expressions".
Some rare cases are not handled (fix is not provided for mentioned error).
For example when switch is used inside:
 - initialization/condition/update part of for loop
 - initializer of class field
 - condition of do-while loop
 - lock expression in synchronized statement
 - any part of assert statement
 - resource initializer of 'try' statement

#IDEA-283208 Fixed
Merge-request: IJ-MR-172146
Merged-by: Marcin Mikosik <marcin.mikosik@jetbrains.com>

GitOrigin-RevId: a2710c49e16b7f495974fb167bcae01b3d850f7b
2025-08-21 09:10:24 +00:00

17 lines
386 B
Java

// "Lift 'throw' out of 'switch' expression" "true-preview"
public class Foo {
public int bar(int param) {
switch (param) {
default -> {
call();
throw <caret>switch (param) {
default -> new ArithmeticException();
};
}
}
}
public int call() {
return 3;
}
}