Files
kotlin-fork/js/js.translator/testData/box/jsAstOptimizations/deadCodeElimination.kt
T
Alexander Korepanov a588e75c11 [JS IR] Optimize JS AST for closures
^KT-58891 Fixed
2023-07-13 16:37:18 +00:00

24 lines
532 B
Kotlin
Vendored

// IGNORE_BACKEND_K2: JS_IR
// FIR works fine, however it generates another names for the temporary variables, therefore ignore it
fun demo(f: () -> String) = f()
// EXPECT_GENERATED_JS: function=test$lambda expect=deadCodeEliminationTestLambda.js
fun test(x: String?): String {
val r = demo {
val z = x ?: run {
return@demo "OK"
}
"Fail 1: $z"
}
return r
}
fun box(): String {
val r = test(null)
if (r != "OK") {
return "Fail test, got $r"
}
return "OK"
}