Skip to content

Make value class with Serializable property automatically Serializable #3061

@Cyberavater

Description

@Cyberavater

What is your use-case and why do you need this feature?
example

value class Color(val value: ULong) 

This value class parameter is already serializable, but when we have another wrapper class that we need to be Serializable!

@Serializable
data class Note(
    val title: String,
    val content: String,
    val color: Color,
    val timestamp: Instant = Clock.System.now(),
    @PrimaryKey(autoGenerate = true) val id: Int,
)

Serializer has not been found for type 'Color'. To use context serializer as fallback, explicitly annotate type or property with @Contextual
We need to write a verbose KSerializer, which could be avoided entirely

Describe the solution you'd like
Serialization compiler to be able to properly generate/understand value class without manually writing KSerializer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions