[IR] Forbid unconditional interpretation of IrGetObjectValue

Earlier we always allowed to interpret `IrGetObjectValue` because
this value is used in const val getter. But now we do a special
check for such getter avoiding visit of `IrGetObjectValue` node.

#KT-59775 Fixed
This commit is contained in:
Ivan Kylchik
2023-07-04 11:21:15 +02:00
committed by Space Team
parent 04f16d75d2
commit d557bcaba4
9 changed files with 98 additions and 13 deletions
@@ -1,15 +1,18 @@
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: NATIVE
// TARGET_BACKEND: JS_IR
// WITH_STDLIB
fun <T> T.id() = this
const val someStr = <!EVALUATED("123")!>"123"<!>
const val otherStr = <!EVALUATED("other")!>"other"<!>
const val oneVal = <!EVALUATED("1")!>1<!>
const val oneUnsignedVal = <!EVALUATED("1")!>1u<!>
const val plus1 = someStr.<!EVALUATED("123other")!>plus(otherStr)<!>
const val plus2 = someStr.<!EVALUATED("1231")!>plus(oneVal)<!>
const val plus3 = someStr.<!EVALUATED("1231")!>plus(oneUnsignedVal)<!>
const val length1 = someStr.<!EVALUATED("3")!>length<!>
const val length2 = otherStr.<!EVALUATED("5")!>length<!>
@@ -31,6 +34,7 @@ const val toString1 = someStr.<!EVALUATED("123")!>toString()<!>
fun box(): String {
if (plus1.id() != "123other") return "Fail 1.1"
if (plus2.id() != "1231") return "Fail 1.2"
if (plus3.id() != "1231") return "Fail 1.3"
if (length1.id() != 3) return "Fail 2.1"
if (length2.id() != 5) return "Fail 2.2"