Skip to content

Deprecate ExecutorCoroutineDispatcher.Key for removal #4333

Open
@qwwdfsad

Description

Originally, it was added as a proof-of-concept of "disjoint polymorphism" in coroutine context elements: https://youtrack.jetbrains.com/issue/KT-36118

In short, for the polymorphic type hierarchy (e.g. ContinuationInterceptor -> CoroutineDispatcher -> ExecutorCoroutineDispatcher) it enables use of the corresponding context keys with the preservation of type properties -- ctx[ContinuationInterceptor] works for all types, ctx[CoroutineDispatcher] works for CD and so on).

The problem with this API (both in the stdlib and coroutines) is that it is error-prone (i.e. the correct implementation is neither ergonomic nor easy to get from the first try, with no clear indication of a bug), can be much more safely and meaningfully, replaced with a corresponding extension (i.e. ctx.job and, potentially, ctx.dispatcher) and leaks implementation details (for example, a dispatcher might be reasonably used with asExectutor() and not be available via ExecutorCoroutineDispatcher).

The API (that is experimental, with ERROR) should be deprecated in the Kotlin and its usages in coroutines

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions