Implement coroutineContext intrinsic

This intrinsic allows coroutine to access its context without suspention
and, furthermore, disabling tail-call optimization.
KT-17609: Fixed
This commit is contained in:
Ilmir Usmanov
2017-10-23 13:38:23 +03:00
parent 0fffb9fb17
commit 817f79520a
28 changed files with 520 additions and 35 deletions
@@ -45,6 +45,19 @@ import kotlin.coroutines.experimental.processBareContinuationResume
public inline suspend fun <T> suspendCoroutineOrReturn(crossinline block: (Continuation<T>) -> Any?): T =
throw NotImplementedError("Implementation is intrinsic")
/**
* Continuation context of current coroutine.
*
* This allows the user code to not pass an extra [CoroutineContext] parameter in basic coroutine builders like [launch] and [async],
* but still provide easy access to coroutine context.
*/
@SinceKotlin("1.2")
@Suppress("WRONG_MODIFIER_TARGET")
public inline suspend val coroutineContext: CoroutineContext
get() {
throw NotImplementedError("Implemented as intrinsic")
}
/**
* This value is used as a return value of [suspendCoroutineOrReturn] `block` argument to state that
* the execution was suspended and will not return any result immediately.