JVM IR: Avoid direct invokes in callable reference tests

Due to the direct invoke optimization, most callable reference tests
were not generating callable references/lambdas.
This commit is contained in:
Steven Schäfer
2022-06-13 14:49:49 +02:00
committed by Alexander Udalov
parent f0238766df
commit 7d59c7689c
123 changed files with 216 additions and 208 deletions
@@ -1,4 +1,4 @@
fun box(): String {
return if ((arrayOf(1, 2, 3)::get)(1) == 2) "OK" else "Fail"
return if ((arrayOf(1, 2, 3)::get).let { it(1) } == 2) "OK" else "Fail"
}
@@ -5,4 +5,4 @@ class A {
}
}
fun box() = (A.Companion::ok)()
fun box() = (A.Companion::ok).let { it() }
@@ -7,11 +7,11 @@ class A {
val aMemberProperty: Int get() = 42.also { result += "A.amp," }
fun test(): String {
(::memberFunction)()
(::aExtensionFunction)()
(::memberFunction).let { it() }
(::aExtensionFunction).let { it() }
(::memberProperty)()
(::aExtensionProperty)()
(::memberProperty).let { it() }
(::aExtensionProperty).let { it() }
return result
}
@@ -21,17 +21,17 @@ class A {
val memberProperty: Int get() = 42.also { result += "B.mp," }
fun test(): String {
(::aMemberFunction)()
(::aExtensionFunction)()
(::aMemberFunction).let { it() }
(::aExtensionFunction).let { it() }
(::aMemberProperty)()
(::aExtensionProperty)()
(::aMemberProperty).let { it() }
(::aExtensionProperty).let { it() }
(::memberFunction)()
(::memberProperty)()
(::memberFunction).let { it() }
(::memberProperty).let { it() }
(::bExtensionFunction)()
(::bExtensionProperty)()
(::bExtensionFunction).let { it() }
(::bExtensionProperty).let { it() }
return result
}
@@ -53,28 +53,28 @@ fun box(): String {
result = ""
with(A()) {
(::memberFunction)()
(::aExtensionFunction)()
(::memberFunction).let { it() }
(::aExtensionFunction).let { it() }
(::memberProperty)()
(::aExtensionProperty)()
(::memberProperty).let { it() }
(::aExtensionProperty).let { it() }
}
if (result != "A.mf,A.ef,A.mp,A.ep,") return "Fail $result"
result = ""
with(A()) {
with(B()) {
(::aMemberFunction)()
(::aExtensionFunction)()
(::aMemberFunction).let { it() }
(::aExtensionFunction).let { it() }
(::aMemberProperty)()
(::aExtensionProperty)()
(::aMemberProperty).let { it() }
(::aExtensionProperty).let { it() }
(::memberFunction)()
(::memberProperty)()
(::memberFunction).let { it() }
(::memberProperty).let { it() }
(::bExtensionFunction)()
(::bExtensionProperty)()
(::bExtensionFunction).let { it() }
(::bExtensionProperty).let { it() }
}
}
if (result != "A.amf,A.ef,A.amp,A.ep,B.mf,B.mp,B.ef,B.ep,") return "Fail $result"
@@ -7,6 +7,6 @@ class Host {
fun box(): String {
Generic(Host()).p::class
(Generic(Host()).p::t)()
return (Generic(Host()).p::v)()
(Generic(Host()).p::t).let { it() }
return (Generic(Host()).p::v).let { it() }
}
@@ -3,13 +3,13 @@
fun box(): String {
val a = intArrayOf(1, 2)
val b = arrayOf("OK")
if ((a::component2)() != 2) {
if ((a::component2).let { it() } != 2) {
return "fail"
}
if ((a::get)(1) != 2) {
if ((a::get).let { it(1) } != 2) {
return "fail"
}
return (b::get)(0)
return (b::get).let { it(0) }
}
@@ -3,4 +3,4 @@ object Singleton {
fun ok() = "OK"
}
fun box() = (Singleton::ok)()
fun box() = (Singleton::ok).let { it() }