Handle @Serializable classes that implement interfaces by delegation
by filtering out delegated properties that end up in irClass.properties() list Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2157
This commit is contained in:
committed by
Space Team
parent
490970e65e
commit
dc0cd61b6f
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.*
|
||||
import kotlinx.serialization.encoding.*
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
@Serializable()
|
||||
class Dto(
|
||||
val data: Map<Int, Int>
|
||||
) : Map<Int, Int> by data
|
||||
|
||||
fun box(): String {
|
||||
val dto = Dto(mapOf(1 to 2))
|
||||
val s = Json.encodeToString(dto)
|
||||
if (s != """{"data":{"1":2}}""") return s
|
||||
val d = Json.decodeFromString<Dto>(s)
|
||||
if (d.size != 1) return "Delegation to Map failed"
|
||||
if (d.data != dto.data) return "Equals failed ${d.data}"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user