Skip to content

serializer<KType>() throws SerializationException when used with sealed class on JS #1116

Closed
@rnett

Description

@rnett

I have a sealed class Trait in common code:

@Serializable
sealed class Trait() {
    abstract val name: String
    ...
}

I want to get it's serializer via serializer<Trait>(). On JVM this works fine and I get a SealedClassSerializer. On JS (IR) I get:

"SerializationException: Serializer for class 'Trait' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
On Kotlin/JS explicitly declared serializer should be used for interfaces and enums without @Serializable annotation
    at platformSpecificSerializerNotRegistered (http://localhost:8080/static/spellbook.js:159984:11)
    at serializer (http://localhost:8080/static/spellbook.js:155641:7)
    at main (http://localhost:8080/static/spellbook.js:188469:25)
    at Object.<anonymous> (http://localhost:8080/static/spellbook.js:195282:3)
    at http://localhost:8080/static/spellbook.js:136257:37
    at Object.<anonymous> (http://localhost:8080/static/spellbook.js:136260:2)
    at Object.H:\Google Drive\My Stuff\spellbook\build\js\packages\spellbook\kotlin\spellbook.js (http://localhost:8080/static/spellbook.js:195286:30)
    at __webpack_require__ (http://localhost:8080/static/spellbook.js:30:30)
    at Object.0 (http://localhost:8080/static/spellbook.js:106:18)
    at __webpack_require__ (http://localhost:8080/static/spellbook.js:30:30)
    at http://localhost:8080/static/spellbook.js:94:18
    at http://localhost:8080/static/spellbook.js:97:10
    at webpackUniversalModuleDefinition (http://localhost:8080/static/spellbook.js:9:23)
    at http://localhost:8080/static/spellbook.js:10:3"

This is with 1.0.0-RC2.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions