JVM_IR: support @JvmStatic transformations in LateinitLowering

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