Properly verify args in string concatenation expression for interpreter

If string concatenation contains object value, then this argument
will not have explicit toString call. We must find and check toString
method manually.

#KT-54615
This commit is contained in:
Ivan Kylchik
2022-10-21 15:44:38 +02:00
committed by Space Team
parent c813e03c1e
commit 5b16b2c71e
13 changed files with 139 additions and 9 deletions
@@ -0,0 +1,18 @@
// FIR_IDENTICAL
object O : Code(0)
open class Code(val x: Int) {
override fun toString() = "$x"
}
class A {
companion object: Code(0)
}
const val toString1 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>O.toString()<!>
const val toString2 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>A.toString()<!>
const val plusString1 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>"string" + O<!>
const val plusString2 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>"string" + A<!>
const val stringConcat1 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>"$O"<!>
const val stringConcat2 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>"$A"<!>