Files
kotlin-fork/compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt
T
Ivan Kylchik 88191e8b1a [IR] Add new test to check that nullable access to enum is not evaluated
Just a safety check. If an expression like `EnumClass.Value?.name` was
evaluated, we would consider it as breaking change.
2023-07-27 22:50:21 +00:00

21 lines
544 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
// TARGET_BACKEND: NATIVE
// WITH_STDLIB
fun <T> T.id() = this
enum class EnumClass {
OK
}
val shouldNotBeEvaluated1 = EnumClass.OK?.name ?: ""
val shouldNotBeEvaluated2 = EnumClass.OK?.name?.toString()
val shouldNotBeEvaluated3 = EnumClass.OK?.name.toString()
fun box(): String {
if (shouldNotBeEvaluated1 != "OK") return "Fail 1"
if (shouldNotBeEvaluated2 != "OK") return "Fail 2"
if (shouldNotBeEvaluated3 != "OK") return "Fail 3"
return shouldNotBeEvaluated1.id()
}