From a48e2315a6fe658f8366a1f4c10060a79bc86f8a Mon Sep 17 00:00:00 2001 From: Veyndan Stuart Date: Thu, 28 Sep 2023 11:25:30 +0200 Subject: [PATCH] Make `Saveable` serializable It was marked with `@Contextual`, but a serializer was never being passed in, therefore it crashes as it can't find a serializer. The class is trivial to serialize, so we can just annotate it with `@Serializable` for a serialization adapter to be generated for us. --- .../kotlin/app/cash/redwood/treehouse/StateSnapshot.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/StateSnapshot.kt b/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/StateSnapshot.kt index fa0b2393a2..fb69964e9b 100644 --- a/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/StateSnapshot.kt +++ b/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/StateSnapshot.kt @@ -18,7 +18,6 @@ package app.cash.redwood.treehouse import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import kotlin.jvm.JvmInline -import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonElement @@ -29,7 +28,7 @@ import kotlinx.serialization.json.intOrNull @Serializable public class StateSnapshot( - public val content: Map>, + public val content: Map>, ) { public fun toValuesMap(): Map> { return content.mapValues { entry -> @@ -89,6 +88,7 @@ private fun JsonElement?.fromJsonElement(): Any { } } +@Serializable public data class Saveable( val isMutableState: Boolean, val value: JsonElement,