Check for name when searching Companion.serializer() function to generate
Name check was forgotten during refactoring, so any user function with matching signature could be overwritten by the plugin, while correct function would not have body. #KT-55682 Fixed
This commit is contained in:
committed by
Space Team
parent
0b4f534d35
commit
bf60819824
+37
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.builtins.*
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Main(val fields: MainFields) {
|
||||
companion object {
|
||||
fun fieldsSerializer(): KSerializer<MainFields> = MainFields.serializer()
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class MainFields(val firstName: String?)
|
||||
|
||||
@Serializable
|
||||
data class Box<T>(val boxed: T) {
|
||||
companion object {
|
||||
fun <T> serializerLike(tSer: KSerializer<T>): KSerializer<List<Box<T>>> = ListSerializer(serializer(tSer))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (Main.fieldsSerializer().descriptor.toString() != "MainFields(firstName: kotlin.String?)") return "Error1"
|
||||
if (MainFields.serializer().descriptor.toString() != "MainFields(firstName: kotlin.String?)") return "Error2"
|
||||
if (Main.serializer().descriptor.toString() != "Main(fields: MainFields)") return "Error3"
|
||||
val boxListDesc = Box.serializerLike(String.serializer()).descriptor
|
||||
if (boxListDesc.toString() != "kotlin.collections.ArrayList(Box(boxed: kotlin.String))") return boxListDesc.toString()
|
||||
val boxDesc = Box.serializer(String.serializer()).descriptor
|
||||
if (boxDesc.toString() != "Box(boxed: kotlin.String)") return boxDesc.toString()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user