JVM_IR KT-45103 optimize direct invoke for lambdas and callable refs

This commit is contained in:
Dmitry Petrov
2021-04-26 17:17:25 +03:00
committed by teamcityserver
parent bfb1a06f3d
commit 851980e36f
124 changed files with 1340 additions and 324 deletions
@@ -1,7 +1,9 @@
// !LANGUAGE: +InlineClasses
fun <T> eval(fn: () -> T) = fn()
inline class R(private val r: Int) {
fun test() = { ok() }()
fun test() = eval { ok() }
private fun ok() = "OK"
}
@@ -1,7 +1,9 @@
// !LANGUAGE: +InlineClasses
fun <T> eval(fn: () -> T) = fn()
inline class R(private val r: Int) {
fun test() = { "OK" }()
fun test() = eval { "OK" }
}
fun box() = R(0).test()
+4 -2
View File
@@ -4,17 +4,19 @@
// !LANGUAGE: +InlineClasses
// WITH_RUNTIME
fun <T> eval(fn: () -> T) = fn()
fun box(): String {
var uint1 = 1u
var uint2 = 2u
var uint3 = 3u
val uintSet = mutableSetOf(uint1)
uintSet.add(uint2);
{
eval {
uintSet.add(uint3)
if (!uintSet.contains(1u)) throw AssertionError()
if (!uintSet.contains(2u)) throw AssertionError()
if (!uintSet.contains(3u)) throw AssertionError()
}()
}
return "OK"
}