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
@@ -16,8 +16,8 @@ class A {
}
suspend fun test(): String {
(::memberFunction)()
(::aExtensionFunction)()
(::memberFunction).let { it() }
(::aExtensionFunction).let { it() }
return result
}
@@ -28,12 +28,12 @@ class A {
}
suspend fun test(): String {
(::aMemberFunction)()
(::aExtensionFunction)()
(::aMemberFunction).let { it() }
(::aExtensionFunction).let { it() }
(::memberFunction)()
(::memberFunction).let { it() }
(::bExtensionFunction)()
(::bExtensionFunction).let { it() }
return result
}
@@ -69,8 +69,8 @@ fun box(): String {
result = ""
builder {
with(A()) {
(::memberFunction)()
(::aExtensionFunction)()
(::memberFunction).let { it() }
(::aExtensionFunction).let { it() }
}
}
if (result != "A.mf,A.ef,") return "Fail $result"
@@ -79,12 +79,12 @@ fun box(): String {
builder {
with(A()) {
with(B()) {
(::aMemberFunction)()
(::aExtensionFunction)()
(::aMemberFunction).let { it() }
(::aExtensionFunction).let { it() }
(::memberFunction)()
(::memberFunction).let { it() }
(::bExtensionFunction)()
(::bExtensionFunction).let { it() }
}
}
}
@@ -2,7 +2,7 @@
import kotlin.coroutines.*
fun box(): String = a { (::write)() }
fun box(): String = a { (::write).let { it() } }
fun builder(c: suspend () -> Unit) {
c.startCoroutine(Continuation(EmptyCoroutineContext) {
@@ -44,7 +44,7 @@ suspend fun fooCallableReference(until: Int): String {
val k = "K"
val dot = "."
suspend fun bar(x: Int): String =
if (x == until) dot else if (x < until) o + (::bar)(x * 2) else k + (::bar)(x - 1)
if (x == until) dot else if (x < until) o + (::bar).let { it(x * 2) } else k + (::bar).let { it(x - 1) }
return bar(1)
}
@@ -53,8 +53,8 @@ suspend fun fooCallableReferenceIndirectRecursion(until: Int): String {
val k = "K"
val dot = "."
suspend fun bar(x: Int): String {
suspend fun innerO() = o + (::bar)(x * 2)
suspend fun innerK() = k + (::bar)(x - 1)
suspend fun innerO() = o + (::bar).let { it(x * 2) }
suspend fun innerK() = k + (::bar).let { it(x - 1) }
return if (x == until) dot else if (x < until) innerO() else innerK()
}
return bar(1)
@@ -29,7 +29,7 @@ inline suspend fun K(block: suspend (String) -> String) = block("K")
suspend fun ok(o: String): String {
return o + run {
if (o != "K") {
(::ok)("K")
(::ok).let { it("K") }
} else ""
}
}