Files
kotlin-fork/compiler/testData/codegen/boxInline/complexStack/breakContinueInInlineLambdaArgument.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

30 lines
657 B
Kotlin
Vendored

// WITH_STDLIB
// KJS_WITH_FULL_RUNTIME
// FILE: 1.kt
inline fun List<String?>.forEachNotNull(s: String, fn: (String, String) -> Unit) {
for (x in this) {
fn(s, x ?: continue)
}
}
inline fun List<String?>.forEachUntilNull(s: String, fn: (String, String) -> Unit) {
for (x in this) {
fn(s, x ?: break)
}
}
// FILE: 2.kt
fun box(): String {
var res = ""
listOf("O", null, "K").forEachNotNull("|") { a, b ->
res += a + b
}
if (res != "|O|K") return res
res = ""
listOf("O", null, "K").forEachUntilNull("|") { a, b ->
res += a + b
}
if (res != "|O") return res
return "OK"
}