Files
kotlin-fork/compiler/testData/ir/interpreter/object.kt
T
Ivan Kylchik 1eca5d1a3b [IR] Rewrite how interpreter works with the Unit result
This way interpreter works in more correct way. Every expression
produces some result, and if we don't need it, the interpreter will
discard it.
2023-07-24 17:20:39 +00:00

26 lines
875 B
Kotlin
Vendored

@CompileTimeCalculation
class A {
companion object {
const val static = <!EVALUATED: `-10`!>{ -10 }()<!> // lambda is needed to avoid computions by old frontend
fun getStaticNumber(): Int {
return Int.MAX_VALUE
}
}
}
@CompileTimeCalculation
object ObjectWithConst {
const val a = 100
const val b = <!EVALUATED: `Value in a: 100`!>concat("Value in a: ", a)<!>
val nonConst = { "Not const field in compile time object" }()
fun concat(first: String, second: Any) = "$first$second"
}
const val numStatic = <!EVALUATED: `-10`!>A.static<!>
const val numStaticFromFun = <!EVALUATED: `2147483647`!>A.getStaticNumber()<!>
const val valFromObject = <!EVALUATED: `Value in a: 100`!>ObjectWithConst.b<!>
const val valFnonConstFromObject = <!EVALUATED: `Not const field in compile time object`!>ObjectWithConst.nonConst<!>