Files
kotlin-fork/compiler/testData/codegen/bytecodeText/whenEnumOptimization/kt14597_full.kt
T
Mads Ager 6fc0de39c2 [PSI2IR] Propagate smart cast information for variable loads.
This gives us more precise type information and can enable backend
optimizations. This was motivated by when expressions not compiled
to table switches in the JVM_IR backend.

Fixed KT-36845.
2021-01-11 12:01:47 +03:00

54 lines
968 B
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.
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