3629a9db30
Serialization requires an instance of the serializer, which cannot be obtained with the passed interface, abstract or sealed class. Therefore, the specifying of such classes in `Serializable` annotation must be prohibited. Fixes https://github.com/Kotlin/kotlinx.serialization/issues/2173 Relates #KT-58036 Merge-request: KT-MR-10753 Merged-by: Sergey Shanshin <Sergey.Shanshin@jetbrains.com>
38 lines
994 B
Kotlin
Vendored
38 lines
994 B
Kotlin
Vendored
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
// FIR_IDENTICAL
|
|
// SKIP_TXT
|
|
// WITH_STDLIB
|
|
|
|
// FILE: test.kt
|
|
import kotlinx.serialization.*
|
|
|
|
|
|
interface InterfaceSerializer: KSerializer<WithInterfaceSerializer>
|
|
|
|
<!ABSTRACT_SERIALIZER_TYPE!>@Serializable(InterfaceSerializer::class)<!>
|
|
class WithInterfaceSerializer(val i: Int)
|
|
|
|
|
|
abstract class AbstractSerializer: KSerializer<WithAbstract>
|
|
|
|
<!ABSTRACT_SERIALIZER_TYPE!>@Serializable(AbstractSerializer::class)<!>
|
|
class WithAbstract(val i: Int)
|
|
|
|
|
|
sealed class SealedSerializer: KSerializer<WithSealed>
|
|
|
|
<!ABSTRACT_SERIALIZER_TYPE!>@Serializable(SealedSerializer::class)<!>
|
|
class WithSealed(val i: Int)
|
|
|
|
@Serializable
|
|
class Holder (
|
|
<!ABSTRACT_SERIALIZER_TYPE!>@Serializable(InterfaceSerializer::class)<!>
|
|
val withInterface: WithInterfaceSerializer,
|
|
|
|
<!ABSTRACT_SERIALIZER_TYPE!>@Serializable(AbstractSerializer::class)<!>
|
|
val withAbstract: WithAbstract,
|
|
|
|
<!ABSTRACT_SERIALIZER_TYPE!>@Serializable(SealedSerializer::class)<!>
|
|
val withSealed: WithSealed
|
|
)
|