Files
kotlin-fork/plugins/kotlinx-serialization/testData/boxIr/serializerFactory.kt
T
Leonid Startsev f3833fdcf8 Add serializer(vararg KSerializer<*>) override from SerializerFactory when necessary
SerializerFactory is an implementation detail for Kotlin/JS and Native:
it should be added as a supertype to a companion object of certain serializable classes
and `serializer(vararg KSerializer<*>)` function from it should be implemented.
Existing implementation added the supertype, but did not add proper override to FirClass
of a companion, which led to various warnings and errors like 'Abstract function 'serializer' is not implemented in non-abstract companion object'.

Also implemented the addition of SerializerFactory supertype to user-defined companions within @Serializable and @MetaSerializable when necessary.

Also set up proper box tests for FIR+Kotlin/JS combination.

#KT-58501 Fixed
#KT-59768 Fixed
2023-07-06 11:38:51 +00:00

27 lines
563 B
Kotlin
Vendored

// WITH_STDLIB
// ISSUE: KT-58501
import kotlinx.serialization.*
import kotlinx.serialization.json.*
@Serializable object Objekt
@Serializable sealed class SealedInterface
@Serializable data object Inheritor: SealedInterface()
@Serializable enum class EnumKlass { INSTANCE }
@Serializable class Plain
fun box(): String {
serializer<Objekt>()
Objekt.serializer()
serializer<EnumKlass>()
EnumKlass.serializer()
serializer<SealedInterface>()
SealedInterface.serializer()
serializer<Plain>()
Plain.serializer()
return "OK"
}