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"
}