Files
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

28 lines
511 B
Kotlin
Vendored

class EncapsulatedEnum<T : Enum<T>>(val value: T)
enum class MyEnum(val value: String) {
VALUE_A("OK"),
VALUE_B("fail"),
}
private fun crash(encapsulated: EncapsulatedEnum<*>) {
val myEnum = encapsulated.value
if (myEnum !is MyEnum) {
return
}
when (myEnum) {
MyEnum.VALUE_A -> res = myEnum.value
MyEnum.VALUE_B -> res = myEnum.value
}
}
var res = "fail"
fun box(): String {
crash(EncapsulatedEnum(MyEnum.VALUE_A))
return res
}
// 1 TABLESWITCH