Files
kotlin-fork/compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt14597_full.kt
T
2020-02-20 14:20:21 +03:00

57 lines
1.1 KiB
Kotlin
Vendored
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// IGNORE_BACKEND: JVM_IR
// TODO KT-36845 Generate enum-based TABLESWITCH/LOOKUPSWITCH on a value with smart cast to enum in JVM_IR
enum class En { A, B, С }
fun box() {
var r = ""
val en: En = En.A
when (en) {
En.A -> { r = "when-1" }
En.B -> {}
En.С -> {}
}
when (en as En) {
En.A -> { r = "when-2" }
En.B -> {}
En.С -> {}
}
// nullable variable
val en2: Any? = En.A
if (en2 is En) {
when (en2) {
En.A -> { r = "when-3" }
En.B -> {}
En.С -> {}
}
when (en2 as En) {
En.A -> { r = "when-4" }
En.B -> {}
En.С -> {}
}
}
// not nullable variable
val en1: Any = En.A
if (en1 is En) {
when (en1) {
En.A -> { r = "when-5" }
En.B -> {}
En.С -> {}
}
// Working without other examples
when (en1 as En) {
En.A -> { r = "when-6" }
En.B -> {}
En.С -> {}
}
}
}
// 6 TABLESWITCH