Files
kotlin-fork/compiler/testData/codegen/box/diagnostics/functions/inference/kt6176.kt
T
Juan Chen 7249d2f889 [FIR] Fix translation of invokes & add return expressions for lambdas
* fixed NoSuchMethod caused by mismatched signatures of the "invoke" method generated for lambda arguments
* added test cases in invoke.kt for KFunction and anonymous functions
* added a transformer to wrap the last expression in the bodies of lambdas with return
2020-02-06 12:44:14 +03:00

26 lines
447 B
Kotlin
Vendored

// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
fun <R> foo(f: () -> R): R = f()
fun <T : Any> some(v: T?, b: T): T {
return foo {
if (v != null) {
v
}
else {
b
}
}
}
fun <T : Any> some1(v: T?, b: T): T {
return foo { if (v != null) v else b }
}
fun box() = when {
some(1, 2) != 1 -> "fail 1"
some(null, 2) != 2 -> "fail 2"
some1(1, 2) != 1 -> "fail 3"
else -> "OK"
}