Files
kotlin-fork/compiler/testData/codegen/box/evaluate/referenceNameFromStaticInDifferentModule.kt
T
Ivan Kylchik 4e740e91f2 Safely unfold callable reference instruction in interpreter
There was an assumption that if receiver exists then parameter will
also exist. This is not true for references marked with `JvmStatic`.
Later in `JvmStaticInObjectLowering` dispatch receiver may be dropped.
2022-08-18 16:50:05 +00:00

36 lines
959 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// MODULE: lib
// FILE: lib.kt
object A {
@JvmStatic
val somePropertyFromObject: Int = 0
@JvmStatic
fun someFunctionFromObject(str: String): String = str
}
class B {
companion object {
@JvmStatic
val somePropertyFromCompanionObject: Int = 0
@JvmStatic
fun someFunctionFromCompanionObject(str: String): String = str
}
}
// MODULE: main(lib)
// FILE: main.kt
fun box(): String {
// `name` call must be optimized with `ConstEvaluationLowering`
if (A::somePropertyFromObject.name != "somePropertyFromObject") return "Fail 1"
if (A::someFunctionFromObject.name != "someFunctionFromObject") return "Fail 2"
if (B.Companion::somePropertyFromCompanionObject.name != "somePropertyFromCompanionObject") return "Fail 3"
if (B.Companion::someFunctionFromCompanionObject.name != "someFunctionFromCompanionObject") return "Fail 4"
return "OK"
}