Replace last SourceInterpreter with specific one in inliner

#KT-38489: Fixed
This commit is contained in:
Ilmir Usmanov
2020-05-06 14:26:03 +02:00
parent 2c88844409
commit 05797afaf8
10 changed files with 164 additions and 74 deletions
@@ -0,0 +1,28 @@
// WITH_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"
}