Update coroutine related runtime parts

This commit is contained in:
Denis Zharkov
2016-12-09 13:04:22 +03:00
committed by Stanislav Erokhin
parent 852a5ee064
commit 72401efb9f
6 changed files with 39 additions and 102 deletions
@@ -78,6 +78,9 @@ fun <T1, T2> Pair<T1, T2>.swap(): Pair<T2, T1> = Pair(second, first)
fun <T: Any> T.check(predicate: (T) -> Boolean): T? = if (predicate(this)) this else null
inline fun <reified T : Any> Any?.safeAs(): T? = this as? T
inline fun <reified T : Any> Any?.cast(): T = this as T
fun <T : Any> constant(calculator: () -> T): T {
val cached = constantMap[calculator]
@Suppress("UNCHECKED_CAST")
@@ -124,4 +127,4 @@ inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
inline fun <T, C : Collection<T>, O> C.ifNotEmpty(body: C.() -> O?): O? = if (isNotEmpty()) this.body() else null
inline fun <T, O> Array<out T>.ifNotEmpty(body: Array<out T>.() -> O?): O? = if (isNotEmpty()) this.body() else null
inline fun <T, O> Array<out T>.ifNotEmpty(body: Array<out T>.() -> O?): O? = if (isNotEmpty()) this.body() else null