Slackbot
07/02/2026, 9:43 AMYoussef Shoaib [MOD]
07/02/2026, 9:49 AMget is getting removed.
Re: harmful: it's because you're assuming a very specific type. In most situations, the interceptor is indeed a dispatcher, but third party libs can mess that up (I've myself written an interceptor that isn't a dispatcher because it was way easier). It's also giving you access to methods that you maybe shouldn't use.
The mechanism they're removing is polymorphic keysYoussef Shoaib [MOD]
07/02/2026, 10:03 AMKey<T> will always give you whatever value is in the context, be it some U : T or not. What's getting removed is the polymorphic keys that would do a cast in addition to retrieving the element from the context, thus surfacing the cast to the user directlyYoussef Shoaib [MOD]
07/02/2026, 11:19 AMTFound is just Liskov substitution. In fact, finding an interceptor would be nonsensical otherwise since it's an interface, so you can't have an object myInterceptor where myInterceptor:: class == ContinuationInterceptor::class.
Personally, I found polymorphic keys to be confusing, especially if you're writing your own coroutine context element, so I'm happy they're going away.Dmitry Khalanskiy [JB]
07/06/2026, 7:08 AMBut what did they mean by ‘as well as the standard library mechanism supporting all this’?We meant kotlinlang.org/api/core/…/-abstract-coroutine-context-key .
Nope,will eventually ditch theCoroutineContext?operator fun get(Key<E>): E?
CoroutineContext itself stays untouched!
What about aConsider this piece of code:that’s usedContinuationInterceptoraas?is ‘too specific’?CoroutineDispatcher: ContinuationInterceptor
val x: List<Int> = listOf(1, 2, 3)
println((x as MutableList<Int>)[0])
MutableList is a more specific type than List<Int>.
What about the cast is ‘unnecessary and even harmful’?Continuing with the
list example above, list[0] would work even without the type cast, so as MutableList<Int> is useless. Moreover, as MutableList<Int> throws an exception if x isn't a mutable list, introducing a new failure mode for no benefit.
Are they just arguing that many functions for example that take aPrecisely!should have been written to take aCoroutineDispatcherinstead? Their hope is that requiring theContinuationInterceptorcast will help people realise in situations where it’s not required that they can forgo it?as? CoroutineDispatcher