diff --git a/kotlinx-coroutines-core/jvm/src/ThreadContextElement.kt b/kotlinx-coroutines-core/jvm/src/ThreadContextElement.kt index 1b825cef01..1a960699c7 100644 --- a/kotlinx-coroutines-core/jvm/src/ThreadContextElement.kt +++ b/kotlinx-coroutines-core/jvm/src/ThreadContextElement.kt @@ -97,26 +97,25 @@ public interface ThreadContextElement : CoroutineContext.Element { * is in a coroutine: * * ``` - * class TraceContextElement(val traceData: TraceData?) : CopyableThreadContextElement { - * companion object Key : CoroutineContext.Key - * override val key: CoroutineContext.Key - * get() = Key + * class TraceContextElement(private val traceData: TraceData?) : CopyableThreadContextElement { + * companion object Key : CoroutineContext.Key + * override val key: CoroutineContext.Key = Key * * override fun updateThreadContext(context: CoroutineContext): TraceData? { * val oldState = traceThreadLocal.get() - * traceThreadLocal.set(data) + * traceThreadLocal.set(traceData) * return oldState * } * - * override fun restoreThreadContext(context: CoroutineContext, oldData: TraceData?) { + * override fun restoreThreadContext(context: CoroutineContext, oldState: TraceData?) { * traceThreadLocal.set(oldState) * } * - * override fun copyForChildCoroutine(): CopyableThreadContextElement { + * override fun copyForChildCoroutine(): CopyableThreadContextElement { * // Copy from the ThreadLocal source of truth at child coroutine launch time. This makes * // ThreadLocal writes between resumption of the parent coroutine and the launch of the * // child coroutine visible to the child. - * return CopyForChildCoroutineElement(traceThreadLocal.get()) + * return TraceContextElement(traceThreadLocal.get()?.copy()) * } * } * ```