KJS IR: Fix KT-45738 - Consider recursive checkForPrimitiveOrPattern

Recursive results from checkForPrimitiveOrPattern were ignored. If it found a case/condition that could not be optimized the resulting "false" was not propagated. This would lead to a "optimized" when without all conditions.
- see KT-45738
- The return is now lifted out of the when to make it more obvious what is going on.
- New test for mixed multiple conditions in when
This commit is contained in:
Andi Wenger
2021-04-28 18:32:27 +02:00
committed by Roman
parent caff279255
commit f9d2ca68ce
10 changed files with 72 additions and 7 deletions
@@ -28124,6 +28124,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleConditions.kt");
}
@TestMetadata("switchOptimizationMultipleMixedConditions.kt")
public void testSwitchOptimizationMultipleMixedConditions() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleMixedConditions.kt");
}
@TestMetadata("switchOptimizationSingleStatementCase.kt")
public void testSwitchOptimizationSingleStatementCase() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationSingleStatementCase.kt");
@@ -27535,6 +27535,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleConditions.kt");
}
@TestMetadata("switchOptimizationMultipleMixedConditions.kt")
public void testSwitchOptimizationMultipleMixedConditions() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleMixedConditions.kt");
}
@TestMetadata("switchOptimizationSingleStatementCase.kt")
public void testSwitchOptimizationSingleStatementCase() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationSingleStatementCase.kt");
@@ -27495,6 +27495,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleConditions.kt");
}
@TestMetadata("switchOptimizationMultipleMixedConditions.kt")
public void testSwitchOptimizationMultipleMixedConditions() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleMixedConditions.kt");
}
@TestMetadata("switchOptimizationSingleStatementCase.kt")
public void testSwitchOptimizationSingleStatementCase() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationSingleStatementCase.kt");
@@ -15568,6 +15568,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/when/switchOptimizationDuplicates.kt");
}
@TestMetadata("switchOptimizationMultipleMixedConditions.kt")
public void testSwitchOptimizationMultipleMixedConditions() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationMultipleMixedConditions.kt");
}
@TestMetadata("switchOptimizationSingleStatementCase.kt")
public void testSwitchOptimizationSingleStatementCase() throws Exception {
runTest("compiler/testData/codegen/box/when/switchOptimizationSingleStatementCase.kt");