Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sealed classes cannot be deserialised on JS side with new IR compiler #234

Closed
zypus opened this issue Feb 18, 2021 · 3 comments
Closed

Sealed classes cannot be deserialised on JS side with new IR compiler #234

zypus opened this issue Feb 18, 2021 · 3 comments

Comments

@zypus
Copy link

zypus commented Feb 18, 2021

I just tried upgrading my fullstack (ktor) project to kvision 4.0.0, however I ran into issues with the IR compiler. Apparently kotlinx.serialization 1.0.0 does not yet support finding the serializer for sealed classes: https://github.com/Kotlin/kotlinx.serialization/issues/1116

ie. something like this in the common module:

@Serializable
sealed class FirmwareLogResponse {
    @Serializable
    object Clear: FirmwareLogResponse()
    @Serializable
    data class InitLog(val logLines: List<LogLine>): FirmwareLogResponse()
    @Serializable
    data class UpdateLog(val logLine: LogLine): FirmwareLogResponse()
    @Serializable
    object LogHeartBeat: FirmwareLogResponse()
}

So this is no direct issue of kvision, but I put this here to be aware of this issue.

It works fine when I use the legacy compiler on the js side.

kotlin.js.compiler=legacy

@rjaros
Copy link
Owner

rjaros commented Feb 18, 2021

Thanks for the information!
I've added this note to KVision documentation as well.

@zypus
Copy link
Author

zypus commented Feb 18, 2021

Thanks I have seen the entry.
Might be worth mentioning in the migration guide as well.

@rjaros
Copy link
Owner

rjaros commented Sep 14, 2022

Should be fixed now

@rjaros rjaros closed this as completed Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants