JVM_IR: do not evaluate receiver of static calls if it is pure
#KT-46802 Fixed
This commit is contained in:
+12
@@ -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")
|
||||
Vendored
+23
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user