Serializer for Nothing not found
See original GitHub issueDescribe the bug
Using Nothing
in a generic type argument fails with an internal error Serializer for element of type Nothing has not been found
.
To Reproduce This reproduces the problem when compiling:
import kotlinx.serialization.Serializable
@Serializable
sealed class SerializableEither<out L, out R> {
@Serializable
data class Left<L>(val value: L) : SerializableEither<L, Nothing>()
@Serializable
data class Right<R>(val value: R) : SerializableEither<Nothing, R>()
}
Full compiler error: https://pastebin.com/FP6zGrDf
Expected behavior
Nothing
should be serializable.
Environment
- Kotlin version: 1.3.60
- Library version: 0.14.0
- Kotlin platforms: JVM
- Gradle version: 5.6.4
- IDE version (if bug is related to the IDE): IntelliJ IDEA 2019.2.4 (Ultimate Edition)
- Runtime version: 11.0.4+10-b304.77 amd64
- Linux 5.0.0-36-generic
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Kotlin - Cannot serialize polymorphic classes. No serializer ...
SerializationException : Serializer for class 'Project' is not found. Mark the class as @Serializable or provide the serializer explicitly ...
Read more >Serializer in serde::ser - Rust - Docs.rs
Enables serializers to serialize byte slices more compactly or more efficiently than other types of slices. If no efficient implementation is available, ...
Read more >Tutorial 1: Serialization - Django REST framework
Tutorial 1: Serialization. Introduction. This tutorial will cover creating a simple pastebin code highlighting Web API. Along the way it will introduce the ......
Read more >Serialization Tutorial - GitHub Pages
An alternative is to serialize nothing to the BSON document when the ... Normally, if no matching field or property is found, an...
Read more >Source code for aiocache.serializers
getLogger(__file__) try: import ujson as json except ImportError: logger.warning("ujson module not found, using json") import json try: import msgpack ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve just started using kotlinx-serialization in a new project and this is basically the first issue I came across, with a compiler error that’s not very helpful (location: “File is unknown”).
Having a default serializer for
Nothing
would avoid that, wouldn’t it?So it would be basically like this:
Such serializer can be applied for types in generic arguments (
data class Left<L>(val value: L) : SerializableEither<L, @Serializable(NotSerializable::class) Nothing>()
).It even can be a default serializer for
Nothing
.