Files
kotlin-fork/compiler/testData/codegen/box/jvmStatic/closure.kt
T
Steven Schäfer 7d59c7689c 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.
2022-07-14 23:24:18 +02:00

51 lines
911 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
object A {
val b: String = "OK"
@JvmStatic val c: String = "OK"
@JvmStatic fun test1() : String {
return {b}.let { it() }
}
@JvmStatic fun test2() : String {
return {test1()}.let { it() }
}
fun test3(): String {
return {"1".test5()}.let { it() }
}
@JvmStatic fun test4(): String {
return {"1".test5()}.let { it() }
}
@JvmStatic fun String.test5() : String {
return {this + b}.let { it() }
}
fun test6(): String {
return {c}.let { it() }
}
}
fun box(): String {
if (A.test1() != "OK") return "fail 1"
if (A.test2() != "OK") return "fail 2"
if (A.test3() != "1OK") return "fail 3"
if (A.test4() != "1OK") return "fail 4"
if (with(A) {"1".test5()} != "1OK") return "fail 5"
if (A.test6() != "OK") return "fail 6"
return "OK"
}