JVM_IR: do not evaluate receiver of static calls if it is pure

#KT-46802 Fixed
This commit is contained in:
pyos
2021-05-19 09:45:11 +02:00
committed by TeamCityServer
parent ae1590d3cf
commit f1f13b6e97
7 changed files with 91 additions and 6 deletions
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// TARGET_BACKEND: JVM
object Test {
@JvmStatic
fun foo(x: String, y: String = "") = x + y
}
fun callFoo(f: (String) -> String, value: String) = f(value)
fun test() = Test
fun box() = callFoo(Test::foo, "O") + callFoo(test()::foo, "K")
@@ -0,0 +1,23 @@
// WITH_RUNTIME
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
object Test {
@JvmStatic
lateinit var value: Any
val isInitialized
get() = Test::value.isInitialized
val isInitializedThroughFn
get() = self()::value.isInitialized
fun self() = Test
}
fun box(): String {
if (Test.isInitialized) return "fail 1"
Test.value = "OK"
if (!Test.isInitializedThroughFn) return "fail 2"
return Test.value as String
}