[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.
This commit is contained in:
Ivan Kylchik
2023-07-17 13:57:20 +02:00
committed by Space Team
parent d0da736b13
commit 88191e8b1a
13 changed files with 91 additions and 0 deletions
@@ -0,0 +1,20 @@
// 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()
}