From 8905586cbb5aac94642f3931ce6052d06e4a0693 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 21 Dec 2021 06:06:45 +0000 Subject: [PATCH] IR KT-50258 rewrite enum-based 'when' more carefully --- .../FirBlackBoxCodegenTestGenerated.java | 18 ++++ .../codegen/FirBytecodeTextTestGenerated.java | 6 ++ .../backend/common/lower/EnumWhenLowering.kt | 95 +++++++++++++------ .../box/when/enumOptimization/kt50258.kt | 23 +++++ .../enumOptimization/nestedWhenInCondition.kt | 19 ++++ .../enumOptimization/nestedWhenInResult.kt | 21 ++++ .../nestedWhenInCondition.kt | 22 +++++ .../codegen/BlackBoxCodegenTestGenerated.java | 18 ++++ .../codegen/BytecodeTextTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 18 ++++ .../codegen/IrBytecodeTextTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 15 +++ .../js/test/JsCodegenBoxTestGenerated.java | 18 ++++ .../test/ir/IrJsCodegenBoxTestGenerated.java | 18 ++++ .../IrCodegenBoxWasmTestGenerated.java | 15 +++ .../blackboxtest/ExternalTestGenerated.java | 18 ++++ 16 files changed, 308 insertions(+), 28 deletions(-) create mode 100644 compiler/testData/codegen/box/when/enumOptimization/kt50258.kt create mode 100644 compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt create mode 100644 compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt create mode 100644 compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1e1f462cecc..69b002e429b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -47838,12 +47838,30 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @Test + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @Test @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @Test + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index 2a46166d11e..0118a6cee1f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -5886,6 +5886,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt index a90c8abe416..01cbd423bc6 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/EnumWhenLowering.kt @@ -5,7 +5,9 @@ package org.jetbrains.kotlin.backend.common.lower -import org.jetbrains.kotlin.backend.common.* +import org.jetbrains.kotlin.backend.common.CommonBackendContext +import org.jetbrains.kotlin.backend.common.FileLoweringPass +import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.declarations.IrEnumEntry @@ -19,14 +21,12 @@ import org.jetbrains.kotlin.ir.types.classifierOrNull import org.jetbrains.kotlin.ir.types.getClass import org.jetbrains.kotlin.ir.types.isNullable import org.jetbrains.kotlin.ir.util.* -import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid /** Look for when-constructs where subject is enum entry. * Replace branches that are comparisons with compile-time known enum entries * with comparisons of ordinals. */ open class EnumWhenLowering(protected val context: CommonBackendContext) : IrElementTransformerVoidWithContext(), FileLoweringPass { - private val subjectWithOrdinalStack = mutableListOf>>() protected open fun mapConstEnumEntry(entry: IrEnumEntry): Int = entry.parentAsClass.declarations.filterIsInstance().indexOf(entry).also { @@ -41,22 +41,24 @@ open class EnumWhenLowering(protected val context: CommonBackendContext) : IrEle } override fun visitBlock(expression: IrBlock): IrExpression { + expression.transformChildrenVoid() + // NB: See BranchingExpressionGenerator to get insight about `when` block translation to IR. if (expression.origin != IrStatementOrigin.WHEN) { - return super.visitBlock(expression) + return expression } // when-block with subject should have two children: temporary variable and when itself. if (expression.statements.size != 2) { - return super.visitBlock(expression) - } - val subject = expression.statements[0] - if (subject !is IrVariable) { - return super.visitBlock(expression) + return expression } + val subject = expression.statements[0] as? IrVariable + ?: return expression val subjectClass = subject.type.getClass() if (subjectClass == null || subjectClass.kind != ClassKind.ENUM_CLASS || subjectClass.isEffectivelyExternal()) { - return super.visitBlock(expression) + return expression } + val irWhen = expression.statements[1] as? IrWhen + ?: return expression // Will be initialized only when we found a branch that compares // subject with compile-time known enum entry. @@ -71,39 +73,75 @@ open class EnumWhenLowering(protected val context: CommonBackendContext) : IrEle } } } - subjectWithOrdinalStack.push(Pair(subject, subjectOrdinalProvider)) - try { - // Process nested `when` and comparisons. - expression.statements[1].transformChildrenVoid(this) - } finally { - subjectWithOrdinalStack.pop() - } + + transformBranches(irWhen, subject, subjectOrdinalProvider) + return expression } - override fun visitCall(expression: IrCall): IrExpression { + private fun transformBranches( + irWhen: IrWhen, + subject: IrVariable, + subjectOrdinalProvider: Lazy + ): IrExpression { + for (irBranch in irWhen.branches) { + irBranch.condition = transformBranchSubexpression(irBranch.condition, subject, subjectOrdinalProvider) + irBranch.result = transformBranchSubexpression(irBranch.result, subject, subjectOrdinalProvider) + } + return irWhen + } + + private fun transformBranchSubexpression( + irExpression: IrExpression, + subject: IrVariable, + subjectOrdinalProvider: Lazy + ): IrExpression = + when (irExpression) { + is IrCall -> { + // Single entry clause: + // when (subject) { + // ENUM_ENTRY -> ... + // } + transformEnumEquals(irExpression, subject, subjectOrdinalProvider) + } + is IrWhen -> { + // Multiple entry clause: + // when (subject) { + // ENUM_ENTRY_1, ENUM_ENTRY_2, ..., ENUM_ENTRY_N -> ... + // } + transformBranches(irExpression, subject, subjectOrdinalProvider) + } + else -> irExpression + } + + private fun transformEnumEquals( + expression: IrCall, + subject: IrVariable, + subjectOrdinalProvider: Lazy + ): IrExpression { // We are looking for branch that is a comparison of the subject and another enum entry. if (expression.symbol != context.irBuiltIns.eqeqSymbol) { - return super.visitCall(expression) + return expression } val lhs = expression.getValueArgument(0)!! val rhs = expression.getValueArgument(1)!! - - val (topmostSubject, topmostOrdinalProvider) = subjectWithOrdinalStack.peek() - ?: return super.visitCall(expression) val other = when { - lhs is IrGetValue && lhs.symbol.owner == topmostSubject -> rhs - rhs is IrGetValue && rhs.symbol.owner == topmostSubject -> lhs - else -> return super.visitCall(expression) + lhs is IrGetValue && lhs.symbol.owner == subject -> + rhs + rhs is IrGetValue && rhs.symbol.owner == subject -> + lhs + else -> + return expression } val entryOrdinal = when { - other is IrGetEnumValue && topmostSubject.type.classifierOrNull?.owner == other.symbol.owner.parent -> + other is IrGetEnumValue && subject.type.classifierOrNull?.owner == other.symbol.owner.parent -> mapConstEnumEntry(other.symbol.owner) other.isNullConst() -> -1 - else -> return super.visitCall(expression) + else -> + return expression } - val subjectOrdinal = topmostOrdinalProvider.value + val subjectOrdinal = subjectOrdinalProvider.value return IrCallImpl( expression.startOffset, expression.endOffset, expression.type, expression.symbol, @@ -114,4 +152,5 @@ open class EnumWhenLowering(protected val context: CommonBackendContext) : IrEle putValueArgument(1, IrConstImpl.int(rhs.startOffset, rhs.endOffset, context.irBuiltIns.intType, entryOrdinal)) } } + } diff --git a/compiler/testData/codegen/box/when/enumOptimization/kt50258.kt b/compiler/testData/codegen/box/when/enumOptimization/kt50258.kt new file mode 100644 index 00000000000..adaaf227157 --- /dev/null +++ b/compiler/testData/codegen/box/when/enumOptimization/kt50258.kt @@ -0,0 +1,23 @@ +enum class MyEnum { + First, + Second +} + +fun getValue() = MyEnum.First + +var result = "Failed" + +fun getLambda(): (Int) -> Unit = + when (val value = getValue()) { + MyEnum.Second -> { _ -> } + MyEnum.First -> { _ -> + if (value == MyEnum.First) { + result = "OK" + } + } + } + +fun box(): String { + getLambda().invoke(2) + return result +} diff --git a/compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt b/compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt new file mode 100644 index 00000000000..d27345bad6c --- /dev/null +++ b/compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt @@ -0,0 +1,19 @@ +enum class ABCD { + A, B, C, D +} + +fun test(x: ABCD, y: ABCD, ok: String): String = + when (x) { + when (y) { + ABCD.A -> ABCD.B + ABCD.B -> ABCD.C + ABCD.C -> ABCD.D + ABCD.D -> ABCD.A + } -> + ok + ABCD.A, ABCD.B, ABCD.C, ABCD.D -> + x.toString() + } + +fun box(): String = + test(ABCD.B, ABCD.A, "O") + test(ABCD.A, ABCD.D, "K") diff --git a/compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt b/compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt new file mode 100644 index 00000000000..ef82ff0e03d --- /dev/null +++ b/compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt @@ -0,0 +1,21 @@ +enum class ABCD { + A, B, C, D +} + +fun test(x: ABCD, y: ABCD, ok: String): String = + when (x) { + ABCD.A, ABCD.B -> + when (y) { + ABCD.A, ABCD.B -> ok + ABCD.C, ABCD.D -> y.toString() + } + ABCD.C, ABCD.D -> + x.toString() + } + +fun box(): String = + test(ABCD.B, ABCD.A, "O") + test(ABCD.A, ABCD.B, "K") + +// CHECK_BYTECODE_TEXT +// JVM_IR_TEMPLATES +// 2 (TABLE|LOOKUP)SWITCH diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt new file mode 100644 index 00000000000..d247302496d --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt @@ -0,0 +1,22 @@ +// IGNORE_BACKEND_FIR: JVM_IR +// FIR_STATUS: FIR+JVM_IR generates TABLESWITCH for nested 'when' only, doesn't look critical. + +// JVM_IR_TEMPLATES +// 2 (TABLE|LOOKUP)SWITCH + +enum class ABCD { + A, B, C, D +} + +fun test(x: ABCD, y: ABCD, ok: String): String = + when (x) { + when (y) { + ABCD.A -> ABCD.B + ABCD.B -> ABCD.C + ABCD.C -> ABCD.D + ABCD.D -> ABCD.A + } -> + ok + ABCD.A, ABCD.B, ABCD.C, ABCD.D -> + x.toString() + } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 20b1b898239..7216fa58db2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -45084,12 +45084,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @Test + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @Test @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @Test + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index 9bd5cd70886..f505c319636 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -5742,6 +5742,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 4027a585b10..2c873a70bfe 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -47838,12 +47838,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @Test + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @Test @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @Test + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index 09b7df8c13d..22017befa6a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -5886,6 +5886,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/nestedWhenInCondition.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 4149f55b221..b0152903060 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -36598,11 +36598,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 04548535667..80661b56d0a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -32756,12 +32756,30 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @Test + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @Test @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @Test + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 07a7ecec85d..265996cffc7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -32858,12 +32858,30 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @Test + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @Test @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @Test + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index ef50fabe7b7..2b81b434865 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -27522,11 +27522,26 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/nonConstantEnum.kt"); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/ExternalTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/ExternalTestGenerated.java index f5e91a48da8..e6600490042 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/ExternalTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/ExternalTestGenerated.java @@ -35169,12 +35169,30 @@ public class ExternalTestGenerated extends AbstractExternalNativeBlackBoxTest { runTest("compiler/testData/codegen/box/when/enumOptimization/kt15806.kt"); } + @Test + @TestMetadata("kt50258.kt") + public void testKt50258() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/kt50258.kt"); + } + @Test @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/box/when/enumOptimization/manyWhensWithinClass.kt"); } + @Test + @TestMetadata("nestedWhenInCondition.kt") + public void testNestedWhenInCondition() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInCondition.kt"); + } + + @Test + @TestMetadata("nestedWhenInResult.kt") + public void testNestedWhenInResult() throws Exception { + runTest("compiler/testData/codegen/box/when/enumOptimization/nestedWhenInResult.kt"); + } + @Test @TestMetadata("nonConstantEnum.kt") public void testNonConstantEnum() throws Exception {