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,9 +16,9 @@ fun L.test() = x
fun S.test() = x
fun box(): String {
if (Z(42)::test.invoke() != 42) throw AssertionError()
if (L(1234L)::test.invoke() != 1234L) throw AssertionError()
if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError()
if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError()
if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError()
if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError()
return "OK"
}
@@ -16,9 +16,9 @@ fun L<Long>.test() = x
fun S<String>.test() = x
fun box(): String {
if (Z(42)::test.invoke() != 42) throw AssertionError()
if (L(1234L)::test.invoke() != 1234L) throw AssertionError()
if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError()
if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError()
if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError()
if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError()
return "OK"
}
@@ -18,9 +18,9 @@ value class S(val x: String) {
}
fun box(): String {
if (Z(42)::test.invoke() != 42) throw AssertionError()
if (L(1234L)::test.invoke() != 1234L) throw AssertionError()
if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError()
if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError()
if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError()
if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError()
return "OK"
}
@@ -18,9 +18,9 @@ value class S<T: String>(val x: T) {
}
fun box(): String {
if (Z(42)::test.invoke() != 42) throw AssertionError()
if (L(1234L)::test.invoke() != 1234L) throw AssertionError()
if (S("abcdef")::test.invoke() != "abcdef") throw AssertionError()
if (Z(42)::test.let { it.invoke() } != 42) throw AssertionError()
if (L(1234L)::test.let { it.invoke() } != 1234L) throw AssertionError()
if (S("abcdef")::test.let { it.invoke() } != "abcdef") throw AssertionError()
return "OK"
}
@@ -12,8 +12,8 @@ class Outer(val z1: Z) {
}
fun box(): String {
assertEquals(Z(1), ::Outer.invoke(Z(1)).z1)
assertEquals(Z(2), Outer::Inner.invoke(Outer(Z(1)), Z(2)).z2)
assertEquals(Z(1), ::Outer.let { it.invoke(Z(1)) }.z1)
assertEquals(Z(2), Outer::Inner.let { it.invoke(Outer(Z(1)), Z(2)) }.z2)
return "OK"
}
}
@@ -12,8 +12,8 @@ class Outer(val z1: Z<Int>) {
}
fun box(): String {
assertEquals(Z(1), ::Outer.invoke(Z(1)).z1)
assertEquals(Z(2), Outer::Inner.invoke(Outer(Z(1)), Z(2)).z2)
assertEquals(Z(1), ::Outer.let { it.invoke(Z(1)) }.z1)
assertEquals(Z(2), Outer::Inner.let { it.invoke(Outer(Z(1)), Z(2)) }.z2)
return "OK"
}
}
@@ -14,7 +14,7 @@ value class S(val x: String)
fun test(aZ: Z, aL: L, aS: S) = "${aZ.x} ${aL.x} ${aS.x}"
fun box(): String {
if (::test.invoke(Z(1), L(1L), S("abc")) != "1 1 abc") throw AssertionError()
if (::test.let { it.invoke(Z(1), L(1L), S("abc")) } != "1 1 abc") throw AssertionError()
return "OK"
}
@@ -14,7 +14,7 @@ value class S<T: String>(val x: T)
fun test(aZ: Z<Int>, aL: L<Long>, aS: S<String>) = "${aZ.x} ${aL.x} ${aS.x}"
fun box(): String {
if (::test.invoke(Z(1), L(1L), S("abc")) != "1 1 abc") throw AssertionError()
if (::test.let { it.invoke(Z(1), L(1L), S("abc")) } != "1 1 abc") throw AssertionError()
return "OK"
}
@@ -16,9 +16,9 @@ fun L.test() = x
fun S.test() = x
fun box(): String {
if (Z::test.invoke(Z(42)) != 42) throw AssertionError()
if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError()
if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError()
if (Z::test.let { it.invoke(Z(42)) } != 42) throw AssertionError()
if (L::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError()
if (S::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError()
return "OK"
}
@@ -16,9 +16,9 @@ fun L<Long>.test() = x
fun S<String>.test() = x
fun box(): String {
if (Z<Int>::test.invoke(Z(42)) != 42) throw AssertionError()
if (L<Long>::test.invoke(L(1234L)) != 1234L) throw AssertionError()
if (S<String>::test.invoke(S("abcdef")) != "abcdef") throw AssertionError()
if (Z<Int>::test.let { it.invoke(Z(42)) } != 42) throw AssertionError()
if (L<Long>::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError()
if (S<String>::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError()
return "OK"
}
@@ -18,9 +18,9 @@ value class S(val x: String) {
}
fun box(): String {
if (Z::test.invoke(Z(42)) != 42) throw AssertionError()
if (L::test.invoke(L(1234L)) != 1234L) throw AssertionError()
if (S::test.invoke(S("abcdef")) != "abcdef") throw AssertionError()
if (Z::test.let { it.invoke(Z(42)) } != 42) throw AssertionError()
if (L::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError()
if (S::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError()
return "OK"
}
@@ -18,9 +18,9 @@ value class S<T: String>(val x: T) {
}
fun box(): String {
if (Z<Int>::test.invoke(Z(42)) != 42) throw AssertionError()
if (L<Long>::test.invoke(L(1234L)) != 1234L) throw AssertionError()
if (S<String>::test.invoke(S("abcdef")) != "abcdef") throw AssertionError()
if (Z<Int>::test.let { it.invoke(Z(42)) } != 42) throw AssertionError()
if (L<Long>::test.let { it.invoke(L(1234L)) } != 1234L) throw AssertionError()
if (S<String>::test.let { it.invoke(S("abcdef")) } != "abcdef") throw AssertionError()
return "OK"
}
@@ -14,7 +14,7 @@ fun box(): String {
val result1 = function1.invoke(Foo("+argument+"), 42)
if (result1.x != "original+argument+42") return "Fail first"
val result2 = Foo::bar.invoke(Foo("explicit"), Foo("+argument2+"), 10)
val result2 = Foo::bar.let { it.invoke(Foo("explicit"), Foo("+argument2+"), 10) }
if (result2.x != "explicit+argument2+10") return "Fail second"
return "OK"
@@ -14,7 +14,7 @@ fun box(): String {
val result1 = function1.invoke(Foo("+argument+"), 42)
if (result1.x != "original+argument+42") return "Fail first"
val result2 = Foo<String>::bar.invoke(Foo("explicit"), Foo("+argument2+"), 10)
val result2 = Foo<String>::bar.let { it.invoke(Foo("explicit"), Foo("+argument2+"), 10) }
if (result2.x != "explicit+argument2+10") return "Fail second"
return "OK"
@@ -4,7 +4,7 @@
OPTIONAL_JVM_INLINE_ANNOTATION
value class R(private val r: Long) {
fun test() = { ok() }()
fun test() = { ok() }.let { it() }
private fun ok() = "OK"
}
@@ -4,7 +4,7 @@
OPTIONAL_JVM_INLINE_ANNOTATION
value class R<T: Long>(private val r: T) {
fun test() = { ok() }()
fun test() = { ok() }.let { it() }
private fun ok() = "OK"
}
@@ -4,7 +4,7 @@
OPTIONAL_JVM_INLINE_ANNOTATION
value class R(private val r: Int) {
fun test() = { ok() }()
fun test() = { ok() }.let { it() }
fun ok() = "OK"
}
@@ -4,7 +4,7 @@
OPTIONAL_JVM_INLINE_ANNOTATION
value class R(private val r: Long) {
fun test() = { ok() }()
fun test() = { ok() }.let { it() }
fun ok() = "OK"
}
@@ -4,7 +4,7 @@
OPTIONAL_JVM_INLINE_ANNOTATION
value class R<T: Long>(private val r: T) {
fun test() = { ok() }()
fun test() = { ok() }.let { it() }
fun ok() = "OK"
}
@@ -4,7 +4,7 @@
OPTIONAL_JVM_INLINE_ANNOTATION
value class R<T: Int>(private val r: T) {
fun test() = { ok() }()
fun test() = { ok() }.let { it() }
fun ok() = "OK"
}
@@ -67,7 +67,7 @@ private fun testDelegateStr() {
localD = 1234
if (localD != 1234) throw AssertionError()
if (backing != 1234) throw AssertionError()
}()
}.let { it() }
}
private fun testDelegateInt() {
@@ -79,7 +79,7 @@ private fun testDelegateInt() {
localD = 1234
if (localD != 1234) throw AssertionError()
if (backing != 1234) throw AssertionError()
}()
}.let { it() }
}
private fun testDelegateLong() {
@@ -91,5 +91,5 @@ private fun testDelegateLong() {
localD = 1234
if (localD != 1234) throw AssertionError()
if (backing != 1234) throw AssertionError()
}()
}.let { it() }
}
@@ -67,7 +67,7 @@ private fun testDelegateStr() {
localD = 1234
if (localD != 1234) throw AssertionError()
if (backing != 1234) throw AssertionError()
}()
}.let { it() }
}
private fun testDelegateInt() {
@@ -79,7 +79,7 @@ private fun testDelegateInt() {
localD = 1234
if (localD != 1234) throw AssertionError()
if (backing != 1234) throw AssertionError()
}()
}.let { it() }
}
private fun testDelegateLong() {
@@ -91,5 +91,5 @@ private fun testDelegateLong() {
localD = 1234
if (localD != 1234) throw AssertionError()
if (backing != 1234) throw AssertionError()
}()
}.let { it() }
}