JVM IR: Avoid direct lambda invokes in inline tests

This commit is contained in:
Steven Schäfer
2022-06-13 15:13:04 +02:00
committed by Alexander Udalov
parent f0760e0550
commit 2acfb3a41f
117 changed files with 211 additions and 210 deletions
@@ -87,7 +87,7 @@ fun box(): String {
suspendHere() suspendHere()
result = "OK" result = "OK"
} }
}() }.let { it() }
} }
return "OK" return "OK"
@@ -86,7 +86,7 @@ fun box(): String {
result = "OK" result = "OK"
} }
} }
} () }.let { it() }
return "OK" return "OK"
} }
@@ -18,7 +18,7 @@ interface Base<T> {
inline fun inlineMe(crossinline c: suspend () -> Unit) = object : Base<Unit> { inline fun inlineMe(crossinline c: suspend () -> Unit) = object : Base<Unit> {
override suspend fun generic(): Unit { override suspend fun generic(): Unit {
c(); c();
{}() {}.let { it() }
} }
} }
@@ -10,7 +10,7 @@ object C {
inline fun inlineFun() = { inline fun inlineFun() = {
val O by "K" val O by "K"
O O
}() }.let { it() }
} }
fun box(): String = ForceOutOfOrder.callInline() fun box(): String = ForceOutOfOrder.callInline()
@@ -12,7 +12,7 @@ inline operator fun String.getValue(t:Any?, p: KProperty<*>): String =
inline fun foo(crossinline f: () -> String) = { inline fun foo(crossinline f: () -> String) = {
val x by f() val x by f()
x x
}() }.let { it() }
// FILE: 2.kt // FILE: 2.kt
import test.* import test.*
@@ -4,7 +4,7 @@
package test package test
inline fun bar(crossinline y: () -> String) = { inline fun bar(crossinline y: () -> String) = {
{ { call(y) }() }() { { call(y) }.let { it() } }.let { it() }
} }
public inline fun <T> call(f: () -> T): T = f() public inline fun <T> call(f: () -> T): T = f()
@@ -4,10 +4,10 @@
package test package test
inline fun bar(crossinline y: () -> String) = { inline fun bar(crossinline y: () -> String) = {
{ { call(y) }() }() { { call(y) }.let { it() } }.let { it() }
} }
public inline fun <T> call(crossinline f: () -> T): T = {{ f() }()}() public inline fun <T> call(crossinline f: () -> T): T = {{ f() }.let { it() }}.let { it() }
// FILE: 2.kt // FILE: 2.kt
@@ -20,5 +20,5 @@ fun box(): String {
} }
inline fun bar2(crossinline y: () -> String) = { inline fun bar2(crossinline y: () -> String) = {
{ { call(y) }() }() { { call(y) }.let { it() } }.let { it() }
} }
@@ -6,7 +6,7 @@ internal class A {
inline fun doSomething(): String { inline fun doSomething(): String {
return { return {
"OK" "OK"
}() }.let { it() }
} }
} }
@@ -6,7 +6,7 @@ internal class A {
inline fun doSomething(s: String): String { inline fun doSomething(s: String): String {
return { return {
s s
}() }.let { it() }
} }
} }
@@ -5,11 +5,13 @@
package test package test
inline fun inf(crossinline cif: Any.() -> String): () -> String { inline fun inf(crossinline cif: Any.() -> String): () -> String {
return { // Approximate the types manually to avoid running into KT-30696
val factory: () -> () -> String = {
object : () -> String { object : () -> String {
override fun invoke() = cif() override fun invoke() = cif()
} }
}() }
return factory()
} }
// FILE: 2.kt // FILE: 2.kt
@@ -4,7 +4,7 @@ package test
inline fun test(cond: Boolean, crossinline cif: () -> String): String { inline fun test(cond: Boolean, crossinline cif: () -> String): String {
return if (cond) { return if (cond) {
{ cif() }() { cif() }.let { it() }
} }
else { else {
cif() cif()
@@ -19,6 +19,6 @@ fun box(): String {
return test(true) { return test(true) {
{ {
s s
}() }.let { it() }
} }
} }
@@ -3,7 +3,7 @@ package test
inline fun inline1(crossinline action: () -> Unit) { inline fun inline1(crossinline action: () -> Unit) {
action(); action();
{ action() }() { action() }.let { it() }
} }
inline fun inline2(crossinline action: () -> Unit) = { action() } inline fun inline2(crossinline action: () -> Unit) = { action() }
@@ -17,7 +17,7 @@ import test.*
var result = "fail" var result = "fail"
fun box(): String { fun box(): String {
inline1 { inline1 {
inline2 { { result ="OK" }() }() inline2 { { result ="OK" }.let { it() } }()
} }
return result return result
@@ -26,7 +26,7 @@ class Foo {
ifNotBusyPerform { ifNotBusyPerform {
ifNotBusySayHello() ifNotBusySayHello()
} }
}() }.let { it() }
} }
} }
} }
@@ -10,7 +10,7 @@ import test.*
class C { class C {
val x: String val x: String
init { init {
val y = myRun { { "OK" }() } val y = myRun { { "OK" }.let { it() } }
x = y x = y
} }
@@ -19,7 +19,7 @@ import test.*
class C { class C {
val x: String val x: String
init { init {
val y by myRun { { "OK" }() } val y by myRun { { "OK" }.let { it() } }
x = y x = y
} }
@@ -27,7 +27,7 @@ fun box(): String {
{ {
locusMap = value locusMap = value
gene = "OK" gene = "OK"
}() }.let { it() }
} }
} }
return gene return gene
@@ -20,7 +20,7 @@ fun box(): String {
{ {
value value
gene = "OK" gene = "OK"
}() }.let { it() }
} }
} }
@@ -15,7 +15,7 @@ inline fun testNested(crossinline f: (String) -> Unit) {
} }
inline fun test(crossinline f: (String) -> Unit) { inline fun test(crossinline f: (String) -> Unit) {
testNested { it -> { f(it) }()} testNested { it -> { f(it) }.let { it() } }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -20,10 +20,10 @@ fun box(): String {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
return if (result == "start12") "OK" else "fail: $result" return if (result == "start12") "OK" else "fail: $result"
@@ -5,7 +5,7 @@ package test
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) { inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
{ {
f(arg) f(arg)
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -19,7 +19,7 @@ fun box(): String {
inlineFun("2") { a -> inlineFun("2") { a ->
{ {
result = param + a result = param + a
}() }.let { it() }
} }
@@ -5,7 +5,7 @@ package test
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) { inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
{ {
f(arg) f(arg)
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -21,10 +21,10 @@ fun box(): String {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
return if (result == "start12") "OK" else "fail: $result" return if (result == "start12") "OK" else "fail: $result"
@@ -5,7 +5,7 @@ package test
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) { inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
{ {
f(arg) f(arg)
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -20,9 +20,9 @@ fun box(): String {
inlineFun("2") { a -> inlineFun("2") { a ->
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
} }
}() }.let { it() }
} }
return if (result == "start12") "OK" else "fail: $result" return if (result == "start12") "OK" else "fail: $result"
@@ -15,7 +15,7 @@ inline fun testNested(crossinline f: (String) -> Unit) {
} }
fun test(f: (String) -> Unit) { fun test(f: (String) -> Unit) {
testNested { it -> { f(it) }()} testNested { it -> { f(it) }.let { it() } }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -17,7 +17,7 @@ class B(val o: String, val k: String) {
} }
inline fun test(crossinline f: (String) -> Unit) { inline fun test(crossinline f: (String) -> Unit) {
testNested { it -> { f(it + k) }() } testNested { it -> { f(it + k) }.let { it() } }
} }
@@ -11,7 +11,7 @@ class A {
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) { inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
{ {
f(arg + addParam) f(arg + addParam)
}() }.let { it() }
} }
fun box(): String { fun box(): String {
@@ -21,12 +21,12 @@ class A {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
} }
}() }.let { it() }
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result" return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
} }
@@ -19,10 +19,10 @@ class A {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result" return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
@@ -11,7 +11,7 @@ class A {
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) { inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
{ {
f(arg + addParam) f(arg + addParam)
}() }.let { it() }
} }
@@ -19,7 +19,7 @@ class A {
inlineFun("2") { a -> inlineFun("2") { a ->
{ {
result = param + a result = param + a
}() }.let { it() }
} }
return if (result == "start2_additional_") "OK" else "fail: $result" return if (result == "start2_additional_") "OK" else "fail: $result"
} }
@@ -11,7 +11,7 @@ class A {
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) { inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
{ {
f(arg + addParam) f(arg + addParam)
}() }.let { it() }
} }
@@ -20,9 +20,9 @@ class A {
inlineFun("2") { a -> inlineFun("2") { a ->
{ {
result = param + a result = param + a
}() }.let { it() }
} }
}() }.let { it() }
return if (result == "start2_additional_") "OK" else "fail: $result" return if (result == "start2_additional_") "OK" else "fail: $result"
} }
@@ -11,7 +11,7 @@ class A {
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) { inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
{ {
f(arg + addParam) f(arg + addParam)
}() }.let { it() }
} }
fun box(): String { fun box(): String {
@@ -21,10 +21,10 @@ class A {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result" return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
@@ -11,7 +11,7 @@ class A {
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) { inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
{ {
f(arg + addParam) f(arg + addParam)
}() }.let { it() }
} }
fun box(): String { fun box(): String {
@@ -20,9 +20,9 @@ class A {
inlineFun("2") { a -> inlineFun("2") { a ->
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
} }
}() }.let { it() }
} }
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result" return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
@@ -17,7 +17,7 @@ class B(val o: String, val k: String) {
} }
inline fun test(crossinline f: (String) -> Unit) { inline fun test(crossinline f: (String) -> Unit) {
testNested { it -> { f(it + "K") }() } testNested { it -> { f(it + "K") }.let { it() } }
} }
} }
@@ -18,7 +18,7 @@ class B(val o: String, val k: String) {
} }
fun test(f: (String) -> Unit) { fun test(f: (String) -> Unit) {
testNested { it -> { f(it + k) }() } testNested { it -> { f(it + k) }.let { it() } }
} }
@@ -20,8 +20,8 @@ class B(val o: String, val k: String) {
inline fun test(crossinline f: (String) -> Unit) { inline fun test(crossinline f: (String) -> Unit) {
call { call {
{ {
testNested ({ it -> { f(it + o) }() }) { it -> { f(it + k) }() } testNested ({ it -> { f(it + o) }.let { it() } }) { it -> { f(it + k) }.let { it() } }
}() }.let { it() }
} }
} }
@@ -21,8 +21,8 @@ class B(val o: String, val k: String) {
call { call {
f("start"); f("start");
{ {
testNested ({ it -> { f(it + o) }() }) { it -> { f(it + k) }() } testNested ({ it -> { f(it + o) }.let { it() } }) { it -> { f(it + k) }.let { it() } }
}() }.let { it() }
} }
} }
@@ -7,7 +7,7 @@ class W(val value: Any)
inline fun W.safe(crossinline body : Any.() -> Unit) { inline fun W.safe(crossinline body : Any.() -> Unit) {
{ {
this.value?.body() this.value?.body()
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -7,7 +7,7 @@ class W(val value: Any)
inline fun W.safe(crossinline body : Any.() -> Unit) { inline fun W.safe(crossinline body : Any.() -> Unit) {
{ {
this.value?.body() this.value?.body()
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -19,7 +19,7 @@ fun box(): String {
W("OK").safe { W("OK").safe {
{ {
result = this as String result = this as String
}() }.let { it() }
} }
return result return result
@@ -6,7 +6,7 @@ package test
inline fun foo(value: String, crossinline s: () -> String): String { inline fun foo(value: String, crossinline s: () -> String): String {
val x = { value } val x = { value }
return java.util.concurrent.Callable(x).call() + { s() }() return java.util.concurrent.Callable(x).call() + { s() }.let { it() }
} }
@@ -6,7 +6,7 @@ package test
import java.util.concurrent.Executors import java.util.concurrent.Executors
inline fun doWork(noinline job: ()-> Unit) { inline fun doWork(noinline job: ()-> Unit) {
{ Executors.callable(job).call() } () { Executors.callable(job).call() }.let { it() }
Executors.callable(job).call() Executors.callable(job).call()
} }
@@ -10,7 +10,7 @@ fun test(): String = ""
inline fun String.switchMapOnce(crossinline mapper: (String) -> String): String { inline fun String.switchMapOnce(crossinline mapper: (String) -> String): String {
Callable(::test) Callable(::test)
return { mapper(this) }() return { mapper(this) }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -18,7 +18,7 @@ class A {
inline fun test(crossinline l: () -> String): String { inline fun test(crossinline l: () -> String): String {
return { return {
l() + callK() l() + callK()
}() }.let { it() }
} }
} }
@@ -5,7 +5,7 @@ class C(val x: String) {
fun f(y: String) = C(y).g { x } fun f(y: String) = C(y).g { x }
inline fun g(crossinline h: () -> String) = inline fun g(crossinline h: () -> String) =
{ { h() + x }() }() { { h() + x }.let { it() } }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -5,7 +5,7 @@ class C(val x: String) {
inline fun f(crossinline h: () -> String) = C("").g { x + h() } inline fun f(crossinline h: () -> String) = C("").g { x + h() }
inline fun g(crossinline h: () -> String) = inline fun g(crossinline h: () -> String) =
{ { h() + x }() }() { { h() + x }.let { it() } }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -3,7 +3,7 @@
package test package test
inline fun test(a: Int, b: Long, crossinline c: () -> String): String { inline fun test(a: Int, b: Long, crossinline c: () -> String): String {
return { "${a}_${b}_${c()}"} () return { "${a}_${b}_${c()}" }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -3,8 +3,7 @@
package test package test
inline fun Double.test(a: Int, b: Long, crossinline c: () -> String): String { inline fun Double.test(a: Int, b: Long, crossinline c: () -> String): String {
return { "${this}_${a}_${b}_${c()}" }.let { it() }
return { "${this}_${a}_${b}_${c()}"} ()
} }
// FILE: 2.kt // FILE: 2.kt
@@ -24,7 +24,7 @@ class A {
apply2 { apply2 {
this@linearLayout2::calc this@linearLayout2::calc
}() }()
}() }.let { it() }
} }
} }
+1 -1
View File
@@ -31,7 +31,7 @@ public fun Input.copyTo(output: Output, size: Int): Long {
} }
public inline fun <T> with2(receiver : T, crossinline body : T.() -> Unit) : Unit = {receiver.body()}() public inline fun <T> with2(receiver : T, crossinline body : T.() -> Unit) : Unit = {receiver.body()}.let { it() }
// FILE: 2.kt // FILE: 2.kt
@@ -7,7 +7,7 @@ object ContentTypeByExtension {
{ {
val ext = B("OK") val ext = B("OK")
operation(ext.toLowerCase()) operation(ext.toLowerCase())
}() }.let { it() }
} }
@@ -21,7 +21,7 @@ inline fun vBox(crossinline action: () -> Unit) {
contract { contract {
callsInPlace(action, InvocationKind.EXACTLY_ONCE) callsInPlace(action, InvocationKind.EXACTLY_ONCE)
} }
return { action() }() return { action() }.let { it() }
} }
inline fun button(onAction: () -> Unit) { inline fun button(onAction: () -> Unit) {
@@ -26,7 +26,7 @@ inline fun baz(crossinline exactly_once: () -> Unit) {
callsInPlace(exactly_once, InvocationKind.EXACTLY_ONCE) callsInPlace(exactly_once, InvocationKind.EXACTLY_ONCE)
}; };
{ exactly_once() }() { exactly_once() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -25,7 +25,7 @@ fun box(): String {
x = 42 x = 42
{ {
x x
}() }.let { it() }
} }
return if (res == 42 && x.inc() == 43) "OK" else "Fail: ${x.inc()}" return if (res == 42 && x.inc() == 43) "OK" else "Fail: ${x.inc()}"
} }
@@ -5,7 +5,7 @@ package test
inline fun String.inlineFun(crossinline lambda: () -> String = { this }): String { inline fun String.inlineFun(crossinline lambda: () -> String = { this }): String {
return { return {
this + lambda() this + lambda()
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -5,7 +5,7 @@ package test
inline fun String.inlineFun(crossinline lambda: () -> String, crossinline dlambda: () -> String = { this }): String { inline fun String.inlineFun(crossinline lambda: () -> String, crossinline dlambda: () -> String = { this }): String {
return { return {
"${this} ${lambda()} ${dlambda()}" "${this} ${lambda()} ${dlambda()}"
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -8,7 +8,7 @@ class A(val value: String) {
inline fun String.inlineFun(crossinline lambda: () -> String = { this }): String { inline fun String.inlineFun(crossinline lambda: () -> String = { this }): String {
return { return {
"$value ${this} ${lambda()}" "$value ${this} ${lambda()}"
}() }.let { it() }
} }
} }
@@ -7,7 +7,7 @@ class A(val value: String) {
inline fun String.inlineFun(crossinline lambda: () -> String, crossinline dlambda: () -> String = { this }): String { inline fun String.inlineFun(crossinline lambda: () -> String, crossinline dlambda: () -> String = { this }): String {
return { return {
"$value ${this} ${lambda()} ${dlambda()}" "$value ${this} ${lambda()} ${dlambda()}"
}() }.let { it() }
} }
} }
@@ -6,8 +6,8 @@ inline fun String.inlineFun(crossinline lambda: () -> String = { { this }() }):
return { return {
{ {
this + lambda() this + lambda()
}() }.let { it() }
}() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -8,8 +8,8 @@ class A(val value: String) {
return { return {
{ {
this + lambda() this + lambda()
}() }.let { it() }
}() }.let { it() }
} }
} }
@@ -10,7 +10,7 @@ object C {
inline fun inlineFun() = { inline fun inlineFun() = {
val O by "K" val O by "K"
O O
}() }.let { it() }
} }
// FILE: box.kt // FILE: box.kt
@@ -4,7 +4,7 @@
package test package test
inline fun <R> call(crossinline s: () -> R) = { s() }() inline fun <R> call(crossinline s: () -> R) = { s() }.let { it() }
inline fun test(crossinline z: () -> String) = { z() } inline fun test(crossinline z: () -> String) = { z() }
+1 -1
View File
@@ -14,5 +14,5 @@ enum class Z {
import test.* import test.*
fun box(): String { fun box(): String {
return { enumValueOf<Z>("OK").name } () return { enumValueOf<Z>("OK").name }.let { it() }
} }
@@ -4,7 +4,7 @@
package test package test
inline fun <reified T : Enum<T>> myValueOf(): String { inline fun <reified T : Enum<T>> myValueOf(): String {
return { enumValueOf<T>("OK") }().name return { enumValueOf<T>("OK") }.let { it() }.name
} }
enum class Z { enum class Z {
@@ -8,7 +8,7 @@ inline fun <reified Z : Enum<Z>> myValueOf(): String {
} }
inline fun <reified Y : Enum<Y>> myValueOf2(): String { inline fun <reified Y : Enum<Y>> myValueOf2(): String {
return { enumValueOf<Y>("OK").name }() return { enumValueOf<Y>("OK").name }.let { it() }
} }
@@ -5,7 +5,7 @@
package test package test
inline fun <reified T : Enum<T>> myValues(): String { inline fun <reified T : Enum<T>> myValues(): String {
val values = { enumValues<T>() }() val values = { enumValues<T>() }.let { it() }
return values.joinToString("") return values.joinToString("")
} }
@@ -5,7 +5,7 @@
package test package test
inline fun <reified Y : Enum<Y>> myValues2(): String { inline fun <reified Y : Enum<Y>> myValues2(): String {
val values = { enumValues<Y>() }() val values = { enumValues<Y>() }.let { it() }
return values.joinToString("") return values.joinToString("")
} }
@@ -24,8 +24,8 @@ fun box(): String {
{ {
val q = object {} val q = object {}
s2 = q.javaClass.enclosingMethod.declaringClass.toString() s2 = q.javaClass.enclosingMethod.declaringClass.toString()
}() }.let { it() }
}() }.let { it() }
} }
return "OK" return "OK"
@@ -18,9 +18,9 @@ import zzz.*
fun box(): String { fun box(): String {
val p = { calc { 11 }} () val p = { calc { 11 } }.let { it() }
val z = { calc { 12 }}() val z = { calc { 12 } }.let { it() }
if (p == z) return "fail" if (p == z) return "fail"
@@ -9,7 +9,7 @@ inline fun Int.inlineMethod() : Int {
return noInlineLambda() return noInlineLambda()
} }
inline fun Int.noInlineLambda() = { s++ } () inline fun Int.noInlineLambda() = { s++ }.let { it() }
// FILE: 2.kt // FILE: 2.kt
@@ -4,11 +4,11 @@
package test package test
inline fun <T> doSmth(a: T) : String { inline fun <T> doSmth(a: T) : String {
return {a.toString()}() return { a.toString() }.let { it() }
} }
inline fun <T> doSmth2(a: T) : String { inline fun <T> doSmth2(a: T) : String {
return {{a.toString()}()}() return { { a.toString() }.let { it() } }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -54,7 +54,7 @@ inline fun test2(crossinline param: () -> String): String {
inline fun test22(crossinline param: () -> String): String { inline fun test22(crossinline param: () -> String): String {
var result = "fail1" var result = "fail1"
{{result = param()}()}() { { result = param() }.let { it() } }.let { it() }
return result return result
} }
@@ -5,7 +5,7 @@ package test
inline fun <R> call(crossinline f: () -> R) : R { inline fun <R> call(crossinline f: () -> R) : R {
return {f()} () return { f() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -4,7 +4,7 @@
package test package test
inline fun <R> call(crossinline f: () -> R) : R { inline fun <R> call(crossinline f: () -> R) : R {
return { f() }() return { f() }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -47,7 +47,7 @@ fun fooLongCallableReference(): String {
val r = "O" val r = "O"
val a = run { val a = run {
fun f(x: Long, y: String? = null): String = r + x + y fun f(x: Long, y: String? = null): String = r + x + y
(::f)(4, "K") (::f).let { it(4, "K") }
} }
return a return a
} }
@@ -59,7 +59,7 @@ class A {
override fun run(captured: String): String { override fun run(captured: String): String {
return { return {
callPrivate(capt, captured) callPrivate(capt, captured)
}() }.let { it() }
} }
private fun callPrivate(x: Int, y: String?): String = "O" + x + y private fun callPrivate(x: Int, y: String?): String = "O" + x + y
@@ -19,10 +19,10 @@ fun test1(param: String): String {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
return result return result
@@ -35,8 +35,8 @@ fun test2(param: String): String {
{ {
{ {
result = param + a result = param + a
}() }.let { it() }
}() }.let { it() }
} }
return result return result
@@ -51,10 +51,10 @@ fun test3(param: String): String {
{ {
{ {
result = param + c + a result = param + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
} }
@@ -19,10 +19,10 @@ inline fun test1(crossinline param: () -> String): String {
{ {
{ {
result = param() + c + a result = param() + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
return result return result
@@ -35,8 +35,8 @@ inline fun test2(crossinline param: () -> String): String {
{ {
{ {
result = param() + a result = param() + a
}() }.let { it() }
}() }.let { it() }
} }
return result return result
@@ -51,10 +51,10 @@ inline fun test3(crossinline param: () -> String): String {
{ {
{ {
result = param() + c + a result = param() + c + a
}() }.let { it() }
}() }.let { it() }
} }
}() }.let { it() }
} }
} }
@@ -14,4 +14,4 @@ inline fun foo(f: () -> Unit) {
fun box(): String = (bar@ l@ fun(): String { fun box(): String = (bar@ l@ fun(): String {
foo { return@bar "OK" } foo { return@bar "OK" }
return "fail" return "fail"
}) () }).let { it() }
@@ -10,12 +10,12 @@ inline fun foo(f: () -> Unit) {
fun test(): String = fun (): String { fun test(): String = fun (): String {
foo { return "OK" } foo { return "OK" }
return "fail" return "fail"
} () }.let { it() }
fun test2(): String = (l@ fun (): String { fun test2(): String = (l@ fun (): String {
foo { return@l "OK" } foo { return@l "OK" }
return "fail" return "fail"
}) () }).let { it() }
fun box(): String { fun box(): String {
if (test() != "OK") return "fail 1: ${test()}" if (test() != "OK") return "fail 1: ${test()}"
@@ -5,7 +5,7 @@
// FILE: 1.kt // FILE: 1.kt
package test package test
inline fun <reified T> inlineFun(p: String, lambda: () -> String = { { p + T::class.java.simpleName } () }): String { inline fun <reified T> inlineFun(p: String, lambda: () -> String = { { p + T::class.java.simpleName }.let { it() } }): String {
return lambda() return lambda()
} }
@@ -4,10 +4,10 @@
// FILE: 1.kt // FILE: 1.kt
package test package test
inline fun <reified T> inlineFun(p: String, crossinline lambda: () -> String = { { p + T::class.java.simpleName } () }): String { inline fun <reified T> inlineFun(p: String, crossinline lambda: () -> String = { { p + T::class.java.simpleName }.let { it() } }): String {
return { return {
lambda() lambda()
} () }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -4,10 +4,10 @@
// FILE: 1.kt // FILE: 1.kt
package test package test
inline fun <reified T> inlineFun(crossinline lambda: () -> String = { { T::class.java.simpleName } () }): String { inline fun <reified T> inlineFun(crossinline lambda: () -> String = { { T::class.java.simpleName }.let { it() } }): String {
return { return {
lambda() lambda()
} () }.let { it() }
} }
// FILE: 2.kt // FILE: 2.kt
@@ -5,7 +5,7 @@
// FILE: 1.kt // FILE: 1.kt
package test package test
inline fun <reified T> inlineFun(lambda: () -> String = { { T::class.java.simpleName } () }): String { inline fun <reified T> inlineFun(lambda: () -> String = { { T::class.java.simpleName }.let { it() } }): String {
return lambda() return lambda()
} }
+2 -2
View File
@@ -1,9 +1,9 @@
// FILE: 1.kt // FILE: 1.kt
package test package test
inline fun foo(crossinline x: () -> String) = { x() }() inline fun foo(crossinline x: () -> String) = { x() }.let { it() }
inline fun <reified T> bar() = foo { { T::class.simpleName!! }() } inline fun <reified T> bar() = foo { { T::class.simpleName!! }.let { it() } }
// FILE: 2.kt // FILE: 2.kt
import test.* import test.*
+1 -1
View File
@@ -3,7 +3,7 @@ package test
inline fun foo(x: () -> String) = x() inline fun foo(x: () -> String) = x()
inline fun <reified T> bar() = { foo { { T::class.simpleName!! }() } }() inline fun <reified T> bar() = { foo { { T::class.simpleName!! }.let { it() } } }.let { it() }
// FILE: 2.kt // FILE: 2.kt
import test.* import test.*
+1 -1
View File
@@ -10,7 +10,7 @@ public inline fun <reified T : Any> inlineMeIfYouCan(): String? =
f { f {
T::class.java.getName() T::class.java.getName()
} }
}() }.let { it() }
inline fun f(x: () -> String) = x() inline fun f(x: () -> String) = x()
+1 -1
View File
@@ -6,7 +6,7 @@ import kotlin.reflect.KClass
inline fun <reified T : Any> injectFnc(): KClass<T> = { inline fun <reified T : Any> injectFnc(): KClass<T> = {
T::class T::class
} () }.let { it() }
public class Box public class Box
@@ -4,8 +4,8 @@
package test package test
abstract class Introspector { abstract class Introspector {
abstract inner class SchemaRetriever(val transaction: String) { abstract inner class SchemaRetriever(val transaction: String) {
inline fun inSchema(crossinline modifier: (String) -> Unit) = inline fun inSchema(crossinline modifier: (String) -> Unit)
{ modifier.invoke(transaction) }() { val lambda = { modifier.invoke(transaction) }; lambda() }
} }
} }
@@ -5,7 +5,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/Introspector$SchemaRetriever$inSchema$1 test/Introspector$SchemaRetriever$inSchema$lambda$1
*L *L
1#1,12:1 1#1,12:1
*E *E
@@ -37,7 +37,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/Introspector$SchemaRetriever$inSchema$1 test/Introspector$SchemaRetriever$inSchema$lambda$1
+ 2 2.kt + 2 2.kt
IntrospectorImpl$SchemaRetriever IntrospectorImpl$SchemaRetriever
*L *L
@@ -5,9 +5,9 @@
package builders package builders
inline fun call(crossinline init: () -> Unit) { inline fun call(crossinline init: () -> Unit) {
return { val lambda = {
init() init()
}() }; lambda()
} }
// FILE: 2.kt // FILE: 2.kt
@@ -5,7 +5,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
builders/_1Kt$call$1 builders/_1Kt$call$lambda$1
*L *L
1#1,13:1 1#1,13:1
*E *E
@@ -22,13 +22,13 @@ _2Kt
builders/_1Kt builders/_1Kt
*L *L
1#1,31:1 1#1,31:1
8#2:32 8#2,4:32
*S KotlinDebug *S KotlinDebug
*F *F
+ 1 2.kt + 1 2.kt
_2Kt _2Kt
*L *L
20#1:32 20#1:32,4
*E *E
SMAP SMAP
@@ -37,7 +37,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
builders/_1Kt$call$1 builders/_1Kt$call$lambda$1
+ 2 2.kt + 2 2.kt
_2Kt _2Kt
*L *L
@@ -17,9 +17,9 @@ fun test(): String {
var res = "Fail" var res = "Fail"
call { call {
{ val lambda ={
res = "OK" res = "OK"
}() }; lambda()
} }
return res return res
@@ -3,8 +3,8 @@
package test package test
inline fun annotatedWith2(crossinline predicate: () -> Boolean) = inline fun annotatedWith2(crossinline predicate: () -> Boolean)
{ any { predicate() } }() { val lambda = { any { predicate() } }; lambda() }
inline fun annotatedWith(crossinline predicate: () -> Boolean) = inline fun annotatedWith(crossinline predicate: () -> Boolean) =
@@ -27,7 +27,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$annotatedWith2$1 test/_1Kt$annotatedWith2$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt test/_1Kt
+ 3 2.kt + 3 2.kt
@@ -41,7 +41,7 @@ _2Kt
*S KotlinDebug *S KotlinDebug
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$annotatedWith2$1 test/_1Kt$annotatedWith2$lambda$1
*L *L
7#1:20 7#1:20
7#1:23 7#1:23
@@ -28,10 +28,10 @@ package test
//A lot of blank lines [Don't delete] //A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete] //A lot of blank lines [Don't delete]
inline fun kValue(crossinline s: () -> String) = { s() + "K" }() inline fun kValue(crossinline s: () -> String): String { val lambda = { s() + "K" }; return lambda() }
inline fun lParams(initParams: () -> String = { inline fun lParams(initParams: () -> String = {
{ "" + kValue { "O" } }() val lambda = { "" + kValue { "O" } }; lambda()
}): String { }): String {
val z = "body" val z = "body"
return initParams() return initParams()
@@ -16,7 +16,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt test/_1Kt
*L *L
@@ -25,7 +25,7 @@ test/_1Kt
*S KotlinDebug *S KotlinDebug
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
*L *L
34#1:41 34#1:41
*E *E
@@ -36,9 +36,9 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
*L *L
1#1,40:1 1#1,40:1
34#2:41 34#2:41
@@ -50,7 +50,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
*L *L
1#1,40:1 1#1,40:1
*E *E
@@ -16,7 +16,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt test/_1Kt
*L *L
@@ -25,7 +25,7 @@ test/_1Kt
*S KotlinDebug *S KotlinDebug
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
*L *L
34#1:41 34#1:41
*E *E
@@ -36,9 +36,9 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
*L *L
1#1,40:1 1#1,40:1
34#2:41 34#2:41
@@ -50,7 +50,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
*L *L
1#1,40:1 1#1,40:1
*E *E
@@ -86,7 +86,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt test/_1Kt
*L *L
@@ -95,7 +95,7 @@ test/_1Kt
*S KotlinDebug *S KotlinDebug
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
*L *L
34#1:41 34#1:41
*E *E
@@ -106,9 +106,9 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1$1 test/_1Kt$lParams$1$lambda$1
*L *L
1#1,40:1 1#1,40:1
34#2:41 34#2:41
@@ -29,7 +29,7 @@ package test
//A lot of blank lines [Don't delete] //A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete] //A lot of blank lines [Don't delete]
inline fun kValue(crossinline s: () -> String) = { s() + "K" }() inline fun kValue(crossinline s: () -> String): String { val lambda = { s() + "K" }; return lambda() }
inline fun lParams(initParams: () -> String = { inline fun lParams(initParams: () -> String = {
"" + kValue { "O" } "" + kValue { "O" }
@@ -25,7 +25,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1 test/_1Kt$lParams$1
*L *L
@@ -39,7 +39,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
*L *L
1#1,41:1 1#1,41:1
*E *E
@@ -25,7 +25,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1 test/_1Kt$lParams$1
*L *L
@@ -39,7 +39,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
*L *L
1#1,41:1 1#1,41:1
*E *E
@@ -77,7 +77,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1 test/_1Kt$lParams$1
*L *L
@@ -29,7 +29,7 @@ package test
//A lot of blank lines [Don't delete] //A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete] //A lot of blank lines [Don't delete]
inline fun kValue(crossinline s: () -> String) = { s() + "K" }() inline fun kValue(crossinline s: () -> String): String { val lambda = { s() + "K" }; return lambda() }
inline fun lParams(initParams: () -> String = { inline fun lParams(initParams: () -> String = {
"" + kValue { "O" } "" + kValue { "O" }
@@ -25,7 +25,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1 test/_1Kt$lParams$1
*L *L
@@ -39,7 +39,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
*L *L
1#1,41:1 1#1,41:1
*E *E
@@ -25,7 +25,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1 test/_1Kt$lParams$1
*L *L
@@ -39,7 +39,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
*L *L
1#1,41:1 1#1,41:1
*E *E
@@ -77,7 +77,7 @@ Kotlin
*S Kotlin *S Kotlin
*F *F
+ 1 1.kt + 1 1.kt
test/_1Kt$kValue$1 test/_1Kt$kValue$lambda$1
+ 2 1.kt + 2 1.kt
test/_1Kt$lParams$1 test/_1Kt$lParams$1
*L *L

Some files were not shown because too many files have changed in this diff Show More