Replace last SourceInterpreter with specific one in inliner
#KT-38489: Fixed
This commit is contained in:
+28
@@ -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"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: 1.kt
|
||||
class A(val s: String)
|
||||
|
||||
inline fun inlineMe(limit: Int, c: (String) -> String): A {
|
||||
var index = 0
|
||||
var res: A?
|
||||
while (true) {
|
||||
res = A(c(try {
|
||||
throw IllegalStateException("")
|
||||
} catch (ignored: Throwable) {
|
||||
"OK"
|
||||
})
|
||||
)
|
||||
if (index++ == limit) break
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
fun box(): String {
|
||||
return inlineMe(1) { "OK" }.s
|
||||
}
|
||||
Reference in New Issue
Block a user