Fix for KT-14597: "When" over smartcasted enum is broken and breaks all other "when"
#KT-14597 Fixed
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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 LOOKUPSWITCH
|
||||
Reference in New Issue
Block a user