Sealed class serializer needs access to KClass.serializer(), marked @InternalSerializationApi
See original GitHub issueWhat is your use-case and why do you need this feature?
I just updated to 1.0.0-RC and now I’m getting this error:
This declaration is experimental and its usage must be marked with '@kotlinx.serialization.InternalSerializationApi' or '@OptIn(kotlinx.serialization.InternalSerializationApi::class)'
I can add languageSettings.useExperimentalAnnotation("kotlinx.serialization.InternalSerializationApi")
for now, but I’d like some more clarity on why this method has been marked internal. I’m doing something that doesn’t seem that crazy to me and seems like it should be supported.
Here’s the repro project branch: https://github.com/edenman/kmpPlayground/compare/edenman/kupdates And the problematic call: https://github.com/edenman/kmpPlayground/blob/edenman/kupdates/shared/src/commonMain/kotlin/chat/quill/data/OneOfSerializer.kt#L30
Describe the solution you’d like
A non-internal way to get serializers from a list of KClass
instances
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:10 (7 by maintainers)
Top GitHub Comments
@edenman sure! We realize that
typeOf
approach is not always available, that’s why we leftkClass.serializer
. It can be okay sometimes, but we really want to discourage its usages when possible and give a clear understanding of why this method is potentially dangerous and marked asInternal
@qwwdfsad I’ve already done that: https://youtrack.jetbrains.com/issue/KT-41282