From c2d7b69e5fdfa6bd4162d4e81a0b8b5475e76591 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 11 Jan 2021 17:27:03 +0100 Subject: [PATCH] Remove bytecode text test kt15806.kt It's not correct to expect that the backend generates the `when` in this test as tableswitch because there are only two branches. JVM IR has a cutoff in the when optimization and generates `when`s with fewer than 3 branches as if-else chains, which is probably better. Note that there's also a corresponding box test in when/enumOptimization/, so the backend behavior is still tested. --- .../ir/FirBytecodeTextTestGenerated.java | 5 ---- .../whenEnumOptimization/kt15806.kt | 29 ------------------- .../codegen/BytecodeTextTestGenerated.java | 5 ---- .../ir/IrBytecodeTextTestGenerated.java | 5 ---- 4 files changed, 44 deletions(-) delete mode 100644 compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java index d15c74a552d..5aab02dcb1e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java @@ -4974,11 +4974,6 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt14802.kt"); } - @TestMetadata("kt15806.kt") - public void testKt15806() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt"); - } - @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt"); diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt deleted file mode 100644 index 5be6fa29db8..00000000000 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt +++ /dev/null @@ -1,29 +0,0 @@ -// IGNORE_BACKEND: JVM_IR -// TODO KT-36845 Generate enum-based TABLESWITCH/LOOKUPSWITCH on a value with smart cast to enum in JVM_IR - -private fun Any?.doTheThing(): String { - when (this) { - is String -> return this - is Level -> { - when (this) { - Level.O -> return Level.O.name - Level.K -> return Level.K.name - } - } - - else -> return "fail" - } -} - - -enum class Level { - O, - K -} - - -fun box(): String { - return "O".doTheThing() + Level.K.doTheThing() -} - -// 1 TABLESWITCH diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 6fcef959ef7..748faa774f3 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -4991,11 +4991,6 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt14802.kt"); } - @TestMetadata("kt15806.kt") - public void testKt15806() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt"); - } - @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index f8976f8f180..c6f9499ee57 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -4974,11 +4974,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt14802.kt"); } - @TestMetadata("kt15806.kt") - public void testKt15806() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt15806.kt"); - } - @TestMetadata("manyWhensWithinClass.kt") public void testManyWhensWithinClass() throws Exception { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt");