Do not create cacheableChildSerializers unless it is necessary
Creation of this property in the SerializerIrGenerator.<init> can lead to a 'Serializer not found' internal error when generator is applied to a fully-customized external serializer. In that case, generator is still created, but none of the generateSave/Load functions are called, so cacheableChildSerializers(Property) is not necessary. #KT-57730 Fixed Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2260
This commit is contained in:
committed by
Space Team
parent
54c07f5ebb
commit
d9e16fb76e
@@ -25,4 +25,4 @@ object URLSerializer : KSerializer<URL> {
|
||||
fun box(): String {
|
||||
if (URLSerializer.descriptor.toString() != "PrimitiveDescriptor(java.net.URL)") return URLSerializer.descriptor.toString()
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
// FULL_JDK
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
import java.math.BigDecimal
|
||||
|
||||
@Serializable(with = DataBigDecimal.Serializer::class)
|
||||
data class DataBigDecimal(val value: BigDecimal) {
|
||||
|
||||
@kotlinx.serialization.Serializer(forClass = DataBigDecimal::class)
|
||||
object Serializer : KSerializer<DataBigDecimal> {
|
||||
|
||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("my.DataBigDecimal", PrimitiveKind.STRING)
|
||||
|
||||
override fun deserialize(decoder: Decoder): DataBigDecimal =
|
||||
TODO()
|
||||
|
||||
override fun serialize(encoder: Encoder, value: DataBigDecimal): Unit =
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (DataBigDecimal.Serializer.descriptor.toString() != "PrimitiveDescriptor(my.DataBigDecimal)") return DataBigDecimal.Serializer.descriptor.toString()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user