blob: 9095aa12a2001112c5193aa0e5db34e6c455d00e [file]
// WITH_STDLIB
// WITH_COROUTINES
import kotlin.coroutines.*
public inline fun <reified T> myEmptyArray(): Array<T> = arrayOfNulls<T>(0) as Array<T>
inline fun <reified T> Array<out T>?.myOrEmpty(): Array<out T> = this ?: myEmptyArray<T>()
fun <T> runBlocking(c: suspend () -> T): T {
var res: T? = null
c.startCoroutine(Continuation(EmptyCoroutineContext) {
res = it.getOrThrow()
})
return res!!
}
suspend fun suspendHere(x: String) {}
suspend fun main() {
arrayOf("1").myOrEmpty().forEach { suspendHere(it) }
}
fun box(): String {
runBlocking(::main)
return "OK"
}