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
This commit is contained in:
committed by
Space Team
parent
351e9c7592
commit
f3833fdcf8
+45
@@ -0,0 +1,45 @@
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-59768
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
@Serializable sealed class SealedInterface {
|
||||
companion object {
|
||||
fun unrelated() {}
|
||||
}
|
||||
}
|
||||
@Serializable enum class EnumKlass { INSTANCE;
|
||||
companion object {
|
||||
fun unrelated() {}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable class Plain {
|
||||
companion object {
|
||||
fun unrelated() {}
|
||||
}
|
||||
}
|
||||
|
||||
@MetaSerializable
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY)
|
||||
annotation class MySerializable
|
||||
|
||||
@MySerializable
|
||||
sealed interface SealedMeta {
|
||||
companion object {
|
||||
fun unrelated() {}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
serializer<EnumKlass>()
|
||||
EnumKlass.serializer()
|
||||
serializer<SealedInterface>()
|
||||
SealedInterface.serializer()
|
||||
serializer<Plain>()
|
||||
Plain.serializer()
|
||||
serializer<SealedMeta>()
|
||||
SealedMeta.serializer()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user