Correctly handle star projections according to logic of the old FE.

#KT-54297 Fixed

Properly substitute surrogate UnitSerializer in the Companion.serializer()
function generated on classes that use polymorphic or sealed serializer
by default. (Fixes https://github.com/Kotlin/kotlinx.serialization/issues/1692)
This commit is contained in:
Leonid Startsev
2022-10-03 19:06:48 +02:00
committed by Space Team
parent 2a626b27d3
commit 596949a501
6 changed files with 120 additions and 27 deletions
@@ -0,0 +1,33 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
interface SomeInterface
@Serializable
sealed class SealedMultiple<T1 : SomeInterface, T2 : SomeInterface>
@Serializable
abstract class AbstractMultiple<T1 : SomeInterface, T2 : SomeInterface>
@Serializable
sealed interface SealedInterfaceMultiple<T1 : SomeInterface, T2 : SomeInterface>
interface InterfaceMultiple<T1 : SomeInterface, T2 : SomeInterface>
@Serializable
class ToSerialize(
val a: SealedMultiple<SomeInterface, SomeInterface>,
val b: AbstractMultiple<*, *>,
val c: SealedInterfaceMultiple<*, *>,
val d: InterfaceMultiple<*, *>
)
fun box(): String {
val s = ToSerialize.serializer().descriptor.elementDescriptors.joinToString { it.kind.toString() }
return if (s == "SEALED, OPEN, SEALED, OPEN") "OK" else s
}