Kotlin / kotlinx.coroutines

Library support for Kotlin coroutines
Apache License 2.0
12.98k stars 1.84k forks source link

Gradually introduce SubclassOptInRequired into our codebase #3770

Open qwwdfsad opened 1 year ago

qwwdfsad commented 1 year ago

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-subclass-opt-in-required/

Historically, we have multiple interfaces that are not designed for external implementation, , but are not sealed for various reasons (including historical ones):

It would be nice to adopt the SubclassOptInRequired (available from 1.9.0) in the library to provide explicit programmatic warnings/errors and to prevent issues like https://github.com/Kotlin/kotlinx.coroutines/issues/3729

For "prohibited to implement" interfaces we can introduce the new annotation with a warning (or maybe even an error) and, in the next major release, make the annotation internal itself, so it would be much harder to opt-in

dkhalanskyjb commented 5 months ago

Yet it is possible to implement [a Channel] with a delegation

Yep, even a naive search yields a couple of places: https://grep.app/search?q=by%20channel&filter[lang][0]=Kotlin