From 25ddb415440d57a2f1589038b00d7d65f0458a9e Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 1 Sep 2021 19:29:56 +0800 Subject: [PATCH] Deprecate `EmptyMessageChain.serializer()` for stability concerns --- .../src/commonMain/kotlin/message/data/MessageChain.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt b/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt index af4cc731d..a5f43a97b 100644 --- a/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt +++ b/mirai-core-api/src/commonMain/kotlin/message/data/MessageChain.kt @@ -341,7 +341,7 @@ public sealed interface MessageChain : /** * 不含任何元素的 [MessageChain]. */ -@Serializable(MessageChain.Serializer::class) +//@Serializable(MessageChain.Serializer::class) public object EmptyMessageChain : MessageChain, List by emptyList() { override val size: Int get() = 0 @@ -358,6 +358,14 @@ public object EmptyMessageChain : MessageChain, List by emptyList override fun iterator(): Iterator = EmptyMessageChainIterator + @Suppress("DeprecatedCallableAddReplaceWith") + @Deprecated( + "Serializers for EmptyMessageChain is not provided any more. " + + "Please specify your serial property as MessageChain and use contextual and polymorphic serializers from MessageSerializers.serializersModule.", + level = DeprecationLevel.WARNING + ) // deprecated since 2.8-M1 + public fun serializer(): KSerializer = MessageChain.Serializer + private object EmptyMessageChainIterator : Iterator { override fun hasNext(): Boolean = false override fun next(): Nothing = throw NoSuchElementException("EmptyMessageChain is empty.")