https://kotlinlang.org logo
Title
p

Patrick Ramsey

08/27/2021, 3:31 AM
was just poking around in kotlinx-coroutines. Saw
/**
 * Returns the context of the current coroutine.
 */
@SinceKotlin("1.3")
@Suppress("WRONG_MODIFIER_TARGET")
@InlineOnly
public suspend inline val coroutineContext: CoroutineContext
    get() {
        throw NotImplementedError("Implemented as intrinsic")
    }
That is a wild bit of code. How does a
suspend inline val
exist in the language, and how is it that all it takes to make it work is to suppress the compiler warning that that’s not allowed?
e

ephemient

08/27/2021, 6:30 AM
the definition here is just to make the name and type available to the frontend; the compiler backend recognizes the intrinsic name and replaces it with an implementation that cannot be expressed in pure Kotlin
👍 1
😮 1