Files
kotlin-fork/plugins/kotlinx-serialization/testData/boxIr/externalSerialierJava.kt
T
Leonid Startsev d9e16fb76e 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
2023-04-18 11:04:56 +00:00

29 lines
755 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import java.net.URL
// @Serializer should do nothing if all methods are overriden
@Serializer(forClass = URL::class)
object URLSerializer : KSerializer<URL> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("java.net.URL", PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: URL) {
TODO()
}
override fun deserialize(decoder: Decoder): URL {
TODO()
}
}
fun box(): String {
if (URLSerializer.descriptor.toString() != "PrimitiveDescriptor(java.net.URL)") return URLSerializer.descriptor.toString()
return "OK"
}