We play with nullable types, eg: val a: String? inside our data class. However generated code as well as simple test snippet results in StackOverflowError:
"Nullable String element" {
val str: String? = "abc"
val js: Json = NullableEncoderInstance<String>(String.encoder()).run {
str.encode()
}
println(js)
}
It looks like NullableEncoderInstance cannot see encode extension function of the enclosed encoder:
override fun A?.encode(): Json =
this?.let { a -> encoderA().let { a.encode() } } ?: JsNull
This looks like a shadowing error. It may be trying to get another extfun in a different context. It needs to be imported with a name such as import bla.encode as blaEncode, and then use a.blaEncode()
Hi,
We play with nullable types, eg:
val a: String?
inside our data class. However generated code as well as simple test snippet results in StackOverflowError:It looks like NullableEncoderInstance cannot see
encode
extension function of the enclosed encoder: