3

When browsing through Kotlin source code, I found that in some places NotImplementedError is thrown:

public suspend inline val coroutineContext: CoroutineContext
    get() {
        throw NotImplementedError("Implemented as intrinsic")
    }
public suspend inline fun <T> suspendCoroutineUninterceptedOrReturn(crossinline block: (Continuation<T>) -> Any?): T {
    contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
    throw NotImplementedError("Implementation of suspendCoroutineUninterceptedOrReturn is intrinsic")
}

I assume these are not real not-implemented errors since otherwise code cannot run.

My questions are:

  • what does "intrinsic" mean here and why NotImplementedError is thrown?
  • where could I view the source code for these implementation?
Wang Ke
  • 329
  • 3
  • 11
  • is this function `suspendCoroutineUninterceptedOrReturn` from some library? – Sergio May 04 '22 at 07:34
  • Pretty sure it means it's implemented directly in the compiler and doesn't have a sensible Kotlin source-code equivalent that it could show you. It's not something that you could write yourself in Kotlin. – Tenfour04 May 04 '22 at 12:59
  • I don't have a reference to hand, but I expect it means that the implementation is coming from somewhere else, e.g. hard-coded into the compiler or pulled in from some other Kotlin or native library — possibly selected from among multiple implementations. It may be related to [JVM intrinsics](/questions/19892322/when-will-jvm-use-intrinsics). – gidds May 04 '22 at 22:34

1 Answers1

1

I've found this great answer for you, my dude.

Alex
  • 11
  • 2
  • 1
    Don't add just a link. Bring the content to your answer. Links can be broken\ – Bart May 06 '22 at 21:19
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 07 '22 at 14:38