diff --git a/README-eng.md b/README-eng.md index 7f2751305..1f4fb57a9 100644 --- a/README-eng.md +++ b/README-eng.md @@ -71,7 +71,7 @@ If you meet any problem or have any questions, be free to open a issue. Our goal ## Requirements -Kotlin 1.3.61 +Kotlin 1.3.70 On JVM: Java 6 diff --git a/docs/guide_quick_start.md b/docs/guide_quick_start.md index c4e469fdb..a9d7438e8 100644 --- a/docs/guide_quick_start.md +++ b/docs/guide_quick_start.md @@ -11,7 +11,7 @@ ## 构建需求 -- Kotlin 1.3.61 (必须) +- Kotlin 1.3.70 (必须) - JDK 6 或更高 (必须) - Android SDK 29 (可选, 用于编译安卓目标) diff --git a/gradle.properties b/gradle.properties index 0337a127b..9dcf67f1e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ miraiVersion=0.24.1 kotlin.incremental.multiplatform=true kotlin.parallel.tasks.in.project=true # kotlin -kotlinVersion=1.3.61 +kotlinVersion=1.3.70 # kotlin libraries serializationVersion=0.14.0 coroutinesVersion=1.3.3 diff --git a/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt b/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt index 91bbc6dbf..2249f7d00 100644 --- a/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt +++ b/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt @@ -21,7 +21,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI */ @Suppress("INAPPLICABLE_JVM_NAME") actual object QQAndroid : BotFactory { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) @JvmName("newBot") actual override fun Bot(context: Context, qq: Long, password: String, configuration: BotConfiguration): Bot { return QQAndroidBot(context, BotAccount(qq, password), configuration) @@ -30,7 +30,7 @@ actual object QQAndroid : BotFactory { /** * 使用指定的 [配置][configuration] 构造 [Bot] 实例 */ - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) @JvmName("newBot") actual override fun Bot( context: Context, diff --git a/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt b/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt index be688325d..9c1ac705e 100644 --- a/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt +++ b/mirai-core-qqandroid/src/androidMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt @@ -14,7 +14,7 @@ import net.mamoe.mirai.utils.BotConfiguration import net.mamoe.mirai.utils.Context import net.mamoe.mirai.utils.MiraiInternalAPI -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal actual class QQAndroidBot actual constructor( context: Context, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 500bad2c0..48c95fa03 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -361,7 +361,7 @@ internal class MemberInfoImpl( * 中name/announcement的更改会直接向服务器异步汇报 */ @Suppress("PropertyName") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal class GroupImpl( bot: QQAndroidBot, override val coroutineContext: CoroutineContext, override val id: Long, @@ -373,7 +373,7 @@ internal class GroupImpl( override lateinit var owner: Member - @UseExperimental(MiraiExperimentalAPI::class) + @OptIn(MiraiExperimentalAPI::class) override val botAsMember: Member by lazy { Member(object : MemberInfo { override val nameCard: String @@ -391,7 +391,7 @@ internal class GroupImpl( }) } - @UseExperimental(MiraiExperimentalAPI::class) + @OptIn(MiraiExperimentalAPI::class) override lateinit var botPermission: MemberPermission var _botMuteTimestamp: Int = groupInfo.botMuteRemaining @@ -547,10 +547,10 @@ internal class GroupImpl( TODO("not implemented") } - @UseExperimental(MiraiExperimentalAPI::class) + @OptIn(MiraiExperimentalAPI::class) override fun Member(memberInfo: MemberInfo): Member { return MemberImpl( - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) bot._lowLevelNewQQ(memberInfo) as QQImpl, this, this.coroutineContext, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt index b9fe826c0..e674fb2f5 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt @@ -36,14 +36,14 @@ import net.mamoe.mirai.utils.* import kotlin.collections.asSequence import kotlin.coroutines.CoroutineContext -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal expect class QQAndroidBot constructor( context: Context, account: BotAccount, configuration: BotConfiguration ) : QQAndroidBotBase -@UseExperimental(MiraiInternalAPI::class, MiraiExperimentalAPI::class) +@OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class) internal abstract class QQAndroidBotBase constructor( context: Context, account: BotAccount, @@ -69,7 +69,7 @@ internal abstract class QQAndroidBotBase constructor( override val friends: ContactList = ContactList(LockFreeLinkedList()) override val selfQQ: QQ by lazy { - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) _lowLevelNewQQ(object : FriendInfo { override val uin: Long get() = this@QQAndroidBotBase.uin override val nick: String get() = this@QQAndroidBotBase.nick @@ -101,7 +101,7 @@ internal abstract class QQAndroidBotBase constructor( return groups.delegate.getOrNull(uin) } - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) override suspend fun _lowLevelQueryGroupList(): Sequence { return network.run { FriendList.GetTroopListSimplify(bot.client) @@ -109,7 +109,7 @@ internal abstract class QQAndroidBotBase constructor( }.groups.asSequence().map { it.groupUin.shl(32) and it.groupCode } } - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) override suspend fun _lowLevelQueryGroupInfo(groupCode: Long): GroupInfo = network.run { TroopManagement.GetGroupInfo( client = bot.client, @@ -117,7 +117,7 @@ internal abstract class QQAndroidBotBase constructor( ).sendAndExpect(retry = 2) } - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) override suspend fun _lowLevelQueryGroupMemberList( groupUin: Long, groupCode: Long, @@ -187,7 +187,7 @@ internal abstract class QQAndroidBotBase constructor( } } - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) override suspend fun _lowLevelRecallFriendMessage(friendId: Long, messageId: Long, time: Long) { network.run { val response: PbMessageSvc.PbMsgWithDraw.Response = @@ -198,7 +198,7 @@ internal abstract class QQAndroidBotBase constructor( } } - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) override suspend fun _lowLevelRecallGroupMessage(groupId: Long, messageId: Long) { network.run { val response: PbMessageSvc.PbMsgWithDraw.Response = diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt index 87ec126c1..cf463270b 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/Jce.kt @@ -81,7 +81,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo * From: com.qq.taf.jce.JceOutputStream */ @Suppress("unused", "MemberVisibilityCanBePrivate") - @UseExperimental(ExperimentalIoApi::class) + @OptIn(ExperimentalIoApi::class) private open inner class JceEncoder( internal val output: BytePacketBuilder ) : TaggedEncoder() { @@ -102,7 +102,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo else -> throw SerializationException("Primitives are not supported at top-level") } - @UseExperimental(ImplicitReflectionSerializer::class) + @OptIn(ImplicitReflectionSerializer::class) @Suppress("UNCHECKED_CAST", "NAME_SHADOWING") override fun encodeSerializableValue(serializer: SerializationStrategy, value: T) = when (serializer.descriptor) { is MapLikeDescriptor -> { @@ -515,7 +515,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo } - @UseExperimental(ExperimentalUnsignedTypes::class) + @OptIn(ExperimentalUnsignedTypes::class) internal inner class JceInput( @PublishedApi internal val input: ByteReadPacket, @@ -667,7 +667,7 @@ class Jce private constructor(private val charset: JceCharset, context: SerialMo } while (head.type.toInt() != 11) } - @UseExperimental(ExperimentalUnsignedTypes::class) + @OptIn(ExperimentalUnsignedTypes::class) @PublishedApi internal fun skipField(type: Byte) = when (type.toInt()) { 0 -> this.input.discardExact(1) @@ -794,7 +794,7 @@ internal inline fun Jce.JceInput.skipToTagOrNull(tag: Int, block: (JceHead) } } -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) inline class JceHead(private val value: Long) { constructor(tag: Int, type: Byte) : this(tag.toLong().shl(32) or type.toLong()) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt index fbcd66912..2cfea573a 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/MessageSourceImpl.kt @@ -253,7 +253,7 @@ internal class MessageSourceFromSendFriend( val sequenceId: Int, override val originalMessage: MessageChain ) : MessageSourceFromSend() { - @UseExperimental(ExperimentalCoroutinesApi::class) + @OptIn(ExperimentalCoroutinesApi::class) override val id: Long get() = sequenceId.toLong().shl(32) or messageRandom.toLong().and(0xFFFFFFFF) @@ -277,12 +277,12 @@ internal class MessageSourceFromSendGroup( ) : MessageSourceFromSend() { private lateinit var sequenceIdDeferred: Deferred - @UseExperimental(ExperimentalCoroutinesApi::class) + @OptIn(ExperimentalCoroutinesApi::class) override val id: Long get() = sequenceIdDeferred.getCompleted().toLong().shl(32) or messageRandom.toLong().and(0xFFFFFFFF) - @UseExperimental(MiraiExperimentalAPI::class) + @OptIn(MiraiExperimentalAPI::class) internal fun startWaitingSequenceId(coroutineScope: CoroutineScope) { sequenceIdDeferred = coroutineScope.subscribingGetAsync( diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/messages.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/messages.kt index e23516c3b..a66540659 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/messages.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/messages.kt @@ -219,7 +219,7 @@ private val atAllData = ImMsgBody.Elem( ) ) -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal fun MessageChain.toRichTextElems(forGroup: Boolean): MutableList { val elements = mutableListOf() @@ -332,7 +332,7 @@ internal class OnlineFriendImageImpl( } } -@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) +@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) internal fun MsgComm.Msg.toMessageChain(): MessageChain { val elements = this.msgBody.richText.elems @@ -343,7 +343,7 @@ internal fun MsgComm.Msg.toMessageChain(): MessageChain { } // These two functions are not identical, dont combine. -@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) +@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) internal fun ImMsgBody.SourceMsg.toMessageChain(): MessageChain { val elements = this.elems!! @@ -368,7 +368,9 @@ private fun MessageChain.removeAtIfHasQuoteReply(): MessageChain = }.asMessageChain() } else this*/ -@UseExperimental(MiraiInternalAPI::class, ExperimentalUnsignedTypes::class, MiraiDebugAPI::class, LowLevelAPI::class) +@OptIn( + MiraiInternalAPI::class, ExperimentalUnsignedTypes::class, MiraiDebugAPI::class, LowLevelAPI::class +) internal fun List.joinToMessageChain(message: MessageChainBuilder) { this.forEach { when { diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt index f4389c40e..8b0624152 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt @@ -45,7 +45,7 @@ import kotlin.jvm.Volatile import kotlin.time.ExperimentalTime @Suppress("MemberVisibilityCanBePrivate") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler() { override val bot: QQAndroidBot by bot.unsafeWeakRef() override val supervisor: CompletableJob = SupervisorJob(bot.coroutineContext[Job]) @@ -183,7 +183,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler internal var pendingIncomingPackets: LockFreeLinkedList>? = LockFreeLinkedList() - @UseExperimental(MiraiExperimentalAPI::class, ExperimentalTime::class) + @OptIn(MiraiExperimentalAPI::class, ExperimentalTime::class) override suspend fun init(): Unit = coroutineScope { check(bot.isActive) { "bot is dead therefore network can't init" } check(this@QQAndroidBotNetworkHandler.isActive) { "network is dead therefore can't init" } @@ -372,7 +372,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler * * @param input 一个完整的包的内容, 去掉开头的 int 包长度 */ - @UseExperimental(ExperimentalCoroutinesApi::class) + @OptIn(ExperimentalCoroutinesApi::class) fun parsePacketAsync(input: Input): Job { return this.launch(start = CoroutineStart.ATOMIC) { input.use { parsePacket(it) } diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt index 7d2801ffa..0884252c7 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidClient.kt @@ -40,7 +40,7 @@ import net.mamoe.mirai.utils.io.* DOMAINS Pskey: "openmobile.qq.com" */ -@UseExperimental(MiraiExperimentalAPI::class, MiraiInternalAPI::class) +@OptIn(MiraiExperimentalAPI::class, MiraiInternalAPI::class) @PublishedApi internal open class QQAndroidClient( context: Context, @@ -158,7 +158,7 @@ internal open class QQAndroidClient( */ val uin: Long get() = _uin - @UseExperimental(RawAccountIdUse::class) + @OptIn(RawAccountIdUse::class) @Suppress("PropertyName") internal var _uin: Long = bot.account.id diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt index 61dd755c2..4e9a962c9 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/HighwayHelper.kt @@ -34,7 +34,7 @@ import net.mamoe.mirai.utils.io.ByteArrayPool import net.mamoe.mirai.utils.io.PlatformSocket import net.mamoe.mirai.utils.io.withUse -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) @Suppress("SpellCheckingInspection") internal suspend fun HttpClient.postImage( htcmd: String, @@ -92,9 +92,9 @@ internal suspend fun HttpClient.postImage( } } == HttpStatusCode.OK -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal object HighwayHelper { - @UseExperimental(InternalCoroutinesApi::class) + @OptIn(InternalCoroutinesApi::class) suspend fun uploadImage( client: QQAndroidClient, serverIp: String, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/highway.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/highway.kt index cf13c882a..3ad908b65 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/highway.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/highway/highway.kt @@ -23,7 +23,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.utils.MiraiInternalAPI import net.mamoe.mirai.utils.io.* -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal fun createImageDataPacketSequence( // RequestDataTrans client: QQAndroidClient, command: String, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/EncryptMethod.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/EncryptMethod.kt index 697028560..aab132ce9 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/EncryptMethod.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/EncryptMethod.kt @@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.cryptor.ECDHKeyPair import net.mamoe.mirai.utils.io.encryptAndWrite import net.mamoe.mirai.utils.io.writeShortLVByteArray -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) internal interface EncryptMethod { val id: Int diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt index 5b42295b3..810d3d680 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/OutgoingPacketAndroid.kt @@ -35,7 +35,7 @@ internal val EMPTY_BYTE_ARRAY = ByteArray(0) * com.tencent.qphone.base.util.CodecWarpper#encodeRequest(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, byte[], int, int, java.lang.String, byte, byte, byte, byte[], byte[], boolean) */ @Deprecated("危险", level = DeprecationLevel.ERROR) -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal inline fun OutgoingPacketFactory<*>.buildOutgoingPacket( client: QQAndroidClient, bodyType: Byte = 1, // 1: PB? @@ -63,7 +63,7 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingPacket( }) } -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket( client: QQAndroidClient, bodyType: Byte = 1, // 1: PB? @@ -96,7 +96,7 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket( } -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket( client: QQAndroidClient, bodyType: Byte = 1, // 1: PB? @@ -127,7 +127,7 @@ internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket( }) } -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal inline fun BytePacketBuilder.writeUniPacket( commandName: String, unknownData: ByteArray, @@ -160,7 +160,7 @@ internal val NO_ENCRYPT: ByteArray = ByteArray(0) /** * com.tencent.qphone.base.util.CodecWarpper#encodeRequest(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, byte[], int, int, java.lang.String, byte, byte, byte, byte[], byte[], boolean) */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket( client: QQAndroidClient, bodyType: Byte, @@ -198,7 +198,7 @@ internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket( private inline val BRP_STUB get() = ByteReadPacket.Empty -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal inline fun BytePacketBuilder.writeSsoPacket( client: QQAndroidClient, subAppId: Long, @@ -264,7 +264,7 @@ internal inline fun BytePacketBuilder.writeSsoPacket( writeIntLVPacket(lengthOffset = { it + 4 }, builder = body) } -@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) +@OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) internal fun BytePacketBuilder.writeOicqRequestPacket( client: QQAndroidClient, encryptMethod: EncryptMethod, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt index 0d01e1bbd..782c638c9 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt @@ -48,7 +48,7 @@ internal sealed class PacketFactory { * * @param TPacket 服务器回复包解析结果 */ -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) internal abstract class OutgoingPacketFactory( /** * 命令名. 如 `wtlogin.login`, `ConfigPushSvc.PushDomain` @@ -117,7 +117,7 @@ internal val PacketLogger: MiraiLoggerWithSwitch = DefaultLogger("Packet").withS /** * 已知的数据包工厂列表. */ -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) internal object KnownPacketFactories { object OutgoingFactories : List> by mutableListOf( WtLogin.Login, @@ -164,7 +164,7 @@ internal object KnownPacketFactories { * full packet without length */ // do not inline. Exceptions thrown will not be reported correctly - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) @Suppress("UNCHECKED_CAST") suspend fun parseIncomingPacket(bot: QQAndroidBot, rawInput: Input, consumer: PacketConsumer) = with(rawInput) { // login @@ -226,7 +226,7 @@ internal object KnownPacketFactories { } } - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) internal suspend fun handleIncomingPacket(it: IncomingPacket, bot: QQAndroidBot, flag2: Int, consumer: PacketConsumer) { if (it.packetFactory == null) { bot.network.logger.debug("Received commandName: ${it.commandName}") @@ -275,7 +275,7 @@ internal object KnownPacketFactories { /** * 解析 SSO 层包装 */ - @UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) + @OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) private fun parseSsoFrame(bot: QQAndroidBot, input: ByteReadPacket): IncomingPacket<*> { val commandName: String val ssoSequenceId: Int @@ -336,7 +336,7 @@ internal object KnownPacketFactories { return IncomingPacket(packetFactory, ssoSequenceId, packet, commandName) } - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) private suspend fun ByteReadPacket.parseOicqResponse( bot: QQAndroidBot, packetFactory: OutgoingPacketFactory, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt index 8afcb7d59..15e3f6cf8 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt @@ -71,7 +71,7 @@ internal class MessageSvc { /** * 获取好友消息和消息记录 */ - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) internal object PbGetMsg : OutgoingPacketFactory("MessageSvc.PbGetMsg") { operator fun invoke( client: QQAndroidClient, @@ -102,7 +102,7 @@ internal class MessageSvc { ) } - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) open class GetMsgSuccess(delegate: List) : Response(MsgSvc.SyncFlag.STOP, delegate) { override fun toString(): String = "MessageSvc.PbGetMsg.GetMsgSuccess(messages=))" } @@ -119,7 +119,7 @@ internal class MessageSvc { object EmptyResponse : GetMsgSuccess(emptyList()) - @UseExperimental(MiraiInternalAPI::class, MiraiExperimentalAPI::class) + @OptIn(MiraiInternalAPI::class, MiraiExperimentalAPI::class) override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response { // 00 00 01 0F 08 00 12 00 1A 34 08 FF C1 C4 F1 05 10 FF C1 C4 F1 05 18 E6 ED B9 C3 02 20 89 FE BE A4 06 28 8A CA 91 D1 0C 48 9B A5 BD 9B 0A 58 DE 9D 99 F8 08 60 1D 68 FF C1 C4 F1 05 70 00 20 02 2A 9D 01 08 F3 C1 C4 F1 05 10 A2 FF 8C F0 03 18 01 22 8A 01 0A 2A 08 A2 FF 8C F0 03 10 DD F1 92 B7 07 18 A6 01 20 0B 28 AE F9 01 30 F4 C1 C4 F1 05 38 A7 E3 D8 D4 84 80 80 80 01 B8 01 CD B5 01 12 08 08 01 10 00 18 00 20 00 1A 52 0A 50 0A 27 08 00 10 F4 C1 C4 F1 05 18 A7 E3 D8 D4 04 20 00 28 0C 30 00 38 86 01 40 22 4A 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91 12 08 0A 06 0A 04 4E 4D 53 4C 12 15 AA 02 12 9A 01 0F 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 12 04 4A 02 08 00 30 01 2A 15 08 97 A2 C1 F1 05 10 95 A6 F5 E5 0C 18 01 30 01 40 01 48 81 01 2A 10 08 D3 F7 B5 F1 05 10 DD F1 92 B7 07 18 01 30 01 38 00 42 00 48 00 val resp = readProtoBuf(MsgSvc.PbGetMsgResp.serializer()) @@ -275,6 +275,7 @@ internal class MessageSvc { } } + @Suppress("FunctionName") inline fun ToFriend( client: QQAndroidClient, toUin: Long, @@ -325,6 +326,7 @@ internal class MessageSvc { } + @Suppress("FunctionName") inline fun ToGroup( client: QQAndroidClient, groupCode: Long, diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt index b17a50d33..010cf65cc 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/OnlinePush.kt @@ -54,7 +54,7 @@ internal class OnlinePush { } } - @UseExperimental(ExperimentalStdlibApi::class) + @OptIn(ExperimentalStdlibApi::class) override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet? { // 00 00 02 E4 0A D5 05 0A 4F 08 A2 FF 8C F0 03 10 DD F1 92 B7 07 18 52 20 00 28 BC 3D 30 8C 82 AB F1 05 38 D2 80 E0 8C 80 80 80 80 02 4A 21 08 E7 C1 AD B8 02 10 01 18 BA 05 22 09 48 69 6D 31 38 38 6D 6F 65 30 06 38 02 42 05 4D 69 72 61 69 50 01 58 01 60 00 88 01 08 12 06 08 01 10 00 18 00 1A F9 04 0A F6 04 0A 26 08 00 10 87 82 AB F1 05 18 B7 B4 BF 30 20 00 28 0C 30 00 38 86 01 40 22 4A 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91 12 E6 03 42 E3 03 12 2A 7B 34 45 31 38 35 38 32 32 2D 30 45 37 42 2D 46 38 30 46 2D 43 35 42 31 2D 33 34 34 38 38 33 37 34 44 33 39 43 7D 2E 6A 70 67 22 00 2A 04 03 00 00 00 32 60 15 36 20 39 36 6B 45 31 41 38 35 32 32 39 64 63 36 39 38 34 37 39 37 37 62 20 20 20 20 20 20 35 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7B 34 45 31 38 35 38 32 32 2D 30 45 37 42 2D 46 38 30 46 2D 43 35 42 31 2D 33 34 34 38 38 33 37 34 44 33 39 43 7D 2E 6A 70 67 31 32 31 32 41 38 C6 BB 8A A9 08 40 FB AE 9E C2 09 48 50 50 41 5A 00 60 01 6A 10 4E 18 58 22 0E 7B F8 0F C5 B1 34 48 83 74 D3 9C 72 59 2F 67 63 68 61 74 70 69 63 5F 6E 65 77 2F 31 30 34 30 34 30 30 32 39 30 2F 36 35 35 30 35 37 31 32 37 2D 32 32 33 33 36 33 38 33 34 32 2D 34 45 31 38 35 38 32 32 30 45 37 42 46 38 30 46 43 35 42 31 33 34 34 38 38 33 37 34 44 33 39 43 2F 31 39 38 3F 74 65 72 6D 3D 32 82 01 57 2F 67 63 68 61 74 70 69 63 5F 6E 65 77 2F 31 30 34 30 34 30 30 32 39 30 2F 36 35 35 30 35 37 31 32 37 2D 32 32 33 33 36 33 38 33 34 32 2D 34 45 31 38 35 38 32 32 30 45 37 42 46 38 30 46 43 35 42 31 33 34 34 38 38 33 37 34 44 33 39 43 2F 30 3F 74 65 72 6D 3D 32 B0 01 4D B8 01 2E C8 01 FF 05 D8 01 4D E0 01 2E FA 01 59 2F 67 63 68 61 74 70 69 63 5F 6E 65 77 2F 31 30 34 30 34 30 30 32 39 30 2F 36 35 35 30 35 37 31 32 37 2D 32 32 33 33 36 33 38 33 34 32 2D 34 45 31 38 35 38 32 32 30 45 37 42 46 38 30 46 43 35 42 31 33 34 34 38 38 33 37 34 44 33 39 43 2F 34 30 30 3F 74 65 72 6D 3D 32 80 02 4D 88 02 2E 12 45 AA 02 42 50 03 60 00 68 00 9A 01 39 08 09 20 BF 50 80 01 01 C8 01 00 F0 01 00 F8 01 00 90 02 00 98 03 00 A0 03 20 B0 03 00 C0 03 00 D0 03 00 E8 03 00 8A 04 04 08 02 08 01 90 04 80 80 80 10 B8 04 00 C0 04 00 12 06 4A 04 08 00 40 01 12 14 82 01 11 0A 09 48 69 6D 31 38 38 6D 6F 65 18 06 20 08 28 03 10 8A CA 9D A1 07 1A 00 if (!bot.firstLoginSucceed) return null @@ -93,7 +93,7 @@ internal class OnlinePush { internal object PbPushTransMsg : IncomingPacketFactory("OnlinePush.PbPushTransMsg", "OnlinePush.RespPush") { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) @ExperimentalUnsignedTypes override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet { val content = this.readProtoBuf(OnlinePushTrans.PbMsgInfo.serializer()) @@ -184,7 +184,7 @@ internal class OnlinePush { //0C 01 B1 89 BE 09 5E 3D 72 A6 00 01 73 68 FC 06 00 00 00 3C internal object ReqPush : IncomingPacketFactory("OnlinePush.ReqPush", "OnlinePush.RespPush") { @ExperimentalUnsignedTypes - @UseExperimental(ExperimentalStdlibApi::class) + @OptIn(ExperimentalStdlibApi::class) override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet { val reqPushMsg = decodeUniPacket(OnlinePushPack.SvcReqPushMsg.serializer(), "req") diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/WtLogin.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/WtLogin.kt index 3de2fb8e0..95870eedf 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/WtLogin.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/WtLogin.kt @@ -29,7 +29,7 @@ internal class WtLogin { * OicqRequest */ @Suppress("FunctionName") - @UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) + @OptIn(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) internal object Login : OutgoingPacketFactory("wtlogin.login") { private const val subAppId = 537062845L @@ -121,7 +121,7 @@ internal class WtLogin { private const val appId = 16L private const val subAppId = 537062845L - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) operator fun invoke( client: QQAndroidClient ): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId -> @@ -303,7 +303,7 @@ internal class WtLogin { } @InternalAPI - @UseExperimental(MiraiDebugAPI::class) + @OptIn(MiraiDebugAPI::class) override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacketResponse { discardExact(2) // subCommand @@ -352,7 +352,7 @@ internal class WtLogin { } @InternalAPI - @UseExperimental(MiraiDebugAPI::class) + @OptIn(MiraiDebugAPI::class) private fun onSolveLoginCaptcha(tlvMap: TlvMap, bot: QQAndroidBot): LoginPacketResponse.Captcha { /* java.lang.IllegalStateException: UNKNOWN CAPTCHA QUESTION: @@ -388,7 +388,7 @@ internal class WtLogin { error("UNKNOWN CAPTCHA, tlvMap=" + tlvMap._miraiContentToString()) } - @UseExperimental(MiraiDebugAPI::class) + @OptIn(MiraiDebugAPI::class) private fun onLoginSuccess(tlvMap: TlvMap, bot: QQAndroidBot): LoginPacketResponse.Success { val client = bot.client //println("TLV KEYS: " + tlvMap.keys.joinToString { it.contentToString() }) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt index ba27ce7d5..3b41ac790 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt @@ -21,7 +21,7 @@ import kotlin.jvm.JvmName /** * Inline the block */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) @PublishedApi internal inline fun inline(block: () -> R): R { contract { diff --git a/mirai-core-qqandroid/src/commonTest/kotlin/test/printing.kt b/mirai-core-qqandroid/src/commonTest/kotlin/test/printing.kt index f2fc92dac..a3d6d4160 100644 --- a/mirai-core-qqandroid/src/commonTest/kotlin/test/printing.kt +++ b/mirai-core-qqandroid/src/commonTest/kotlin/test/printing.kt @@ -35,7 +35,7 @@ inline fun ByteArray.debugPrintThis(name: String): ByteArray { return this } -@UseExperimental(ExperimentalContracts::class, MiraiInternalAPI::class) +@OptIn(ExperimentalContracts::class, MiraiInternalAPI::class) inline fun Input.debugIfFail(name: String = "", onFail: (ByteArray) -> ByteReadPacket = { it.toReadPacket() }, block: ByteReadPacket.() -> R): R { contract { diff --git a/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt b/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt index ff08d4d16..a65eee482 100644 --- a/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt +++ b/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroid.kt @@ -23,7 +23,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI * QQ for Android */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual object QQAndroid : BotFactory { /** diff --git a/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt b/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt index 5ead6b167..496830926 100644 --- a/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt +++ b/mirai-core-qqandroid/src/jvmMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt @@ -15,11 +15,11 @@ import net.mamoe.mirai.utils.Context import net.mamoe.mirai.utils.ContextImpl import net.mamoe.mirai.utils.MiraiInternalAPI -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) @Suppress("FunctionName") internal fun QQAndroidBot(account: BotAccount, configuration: BotConfiguration): QQAndroidBot = QQAndroidBot(ContextImpl(), account, configuration) -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) internal actual class QQAndroidBot actual constructor( context: Context, account: BotAccount, diff --git a/mirai-core-qqandroid/src/jvmTest/kotlin/test/ProtoBufDataClassGenerator.kt b/mirai-core-qqandroid/src/jvmTest/kotlin/test/ProtoBufDataClassGenerator.kt index 860aa0b78..16e81d303 100644 --- a/mirai-core-qqandroid/src/jvmTest/kotlin/test/ProtoBufDataClassGenerator.kt +++ b/mirai-core-qqandroid/src/jvmTest/kotlin/test/ProtoBufDataClassGenerator.kt @@ -161,7 +161,7 @@ data class PBFieldInfo( } } -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) fun String.generateProtoBufDataClass(): GeneratedClass { if (this.indexOf("extends") == -1) { val javaClassname = substringBetween("class", "{") @@ -367,7 +367,7 @@ fun String.getNumericalValue(): Int? { return this.filter { it in '0'..'9' }.toDoubleOrNull()?.toInt() } -@UseExperimental(MiraiDebugAPI::class) +@OptIn(MiraiDebugAPI::class) fun ProtoType.mapToKotlinType(): String { return when (this) { ProtoType.VAR_INT -> "Int" diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt index 48c629081..558f5bb63 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt @@ -24,7 +24,9 @@ import net.mamoe.mirai.utils.* * @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close]) */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class) +@OptIn( + MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class +) actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaHappyAPI() { actual companion object { /** @@ -234,6 +236,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA */ actual abstract fun close(cause: Throwable?) - @UseExperimental(LowLevelAPI::class, MiraiExperimentalAPI::class) + @OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class) actual final override fun toString(): String = "Bot(${uin})" } \ No newline at end of file diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt index cc2f0a0af..7fcf98fbb 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt @@ -132,7 +132,7 @@ actual abstract class BotJavaHappyAPI actual constructor() { message: String? = null, remark: String? = null ): AddFriendResult { - @UseExperimental(MiraiExperimentalAPI::class) + @OptIn(MiraiExperimentalAPI::class) return runBlocking { addFriend(id, message, remark) } } @@ -170,7 +170,7 @@ actual abstract class BotJavaHappyAPI actual constructor() { } // !! 不要 crossinline, 会编译失败 -@UseExperimental(ExperimentalCoroutinesApi::class) +@OptIn(ExperimentalCoroutinesApi::class) internal fun C.future(block: suspend C.() -> R): Future { val future = object : Future { val value: CompletableDeferred = CompletableDeferred() @@ -215,7 +215,7 @@ internal fun C.future(block: suspend C.() -> R): Future< } launch { - @UseExperimental(ExperimentalCoroutinesApi::class) + @OptIn(ExperimentalCoroutinesApi::class) future.value.completeWith(kotlin.runCatching { block() }) } diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt index 064245832..d17f11998 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Contact.kt @@ -33,7 +33,7 @@ import net.mamoe.mirai.utils.WeakRefProperty * @author Him188moe */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class) +@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) actual abstract class Contact : CoroutineScope, ContactJavaHappyAPI() { /** * 这个联系人所属 [Bot]. diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Member.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Member.kt index e3e513262..bc017e019 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Member.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/contact/Member.kt @@ -21,7 +21,7 @@ import net.mamoe.mirai.utils.WeakRefProperty * 群成员. */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class) +@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) actual abstract class Member : MemberJavaHappyAPI() { /** * 所在的群. diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt index a9172742c..b20f87bd8 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt @@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI /** * 平台相关扩展 */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual abstract class MessagePacket actual constructor() : MessagePacketBase() { // suspend inline fun uploadImage(image: Bitmap): Image = subject.uploadImage(image) //suspend inline fun uploadImage(image: URL): Image = subject.uploadImage(image) diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt index 3d708e3ed..49755320a 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt @@ -28,7 +28,7 @@ import net.mamoe.mirai.utils.unsafeWeakRef * @see MessageReceipt.sourceTime 源时间 */ @Suppress("FunctionName") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual open class MessageReceipt actual constructor( actual val source: MessageSource, target: C, @@ -94,7 +94,7 @@ actual open class MessageReceipt actual constructor( */ actual open suspend fun quote(): QuoteReplyToSend { this.source.ensureSequenceIdAvailable() - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) return _unsafeQuote() } diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt index 88b572239..ba502818c 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt @@ -23,7 +23,7 @@ import java.io.File /** * 加载一个设备信息. 若文件不存在或为空则随机并创建一个设备信息保存. */ -@UseExperimental(UnstableDefault::class) +@OptIn(UnstableDefault::class) fun File.loadAsDeviceInfo(context: Context): DeviceInfo { if (!this.exists() || this.length() == 0L) { return SystemDeviceInfo(context).also { diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt index 063565c1d..f6859e6c7 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt @@ -80,7 +80,7 @@ actual class PlatformSocket : Closeable { } } - @UseExperimental(ExperimentalIoApi::class) + @OptIn(ExperimentalIoApi::class) actual suspend fun connect(serverHost: String, serverPort: Int) { withContext(Dispatchers.IO) { socket = Socket(serverHost, serverPort) diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt index 9adb9aa12..a2cbc4922 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt @@ -26,7 +26,7 @@ import java.util.zip.Inflater /** * Ktor HttpClient. 不同平台使用不同引擎. */ -@UseExperimental(KtorExperimentalAPI::class) +@OptIn(KtorExperimentalAPI::class) actual val Http: HttpClient get() = HttpClient(CIO) @@ -76,7 +76,7 @@ private inline fun InputStream.readInSequence(block: (Int) -> Unit) { } } -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual fun ByteArray.unzip(offset: Int, length: Int): ByteArray { this.checkOffsetAndLength(offset, length) if (length == 0) return ByteArray(0) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt index e8a25b56e..b606e7ca5 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt @@ -41,7 +41,7 @@ import kotlin.jvm.JvmSynthetic * @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close]) */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, LowLevelAPI::class) +@OptIn(MiraiInternalAPI::class, LowLevelAPI::class) expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor { companion object { /** @@ -241,7 +241,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor { */ abstract fun close(cause: Throwable? = null) - @UseExperimental(LowLevelAPI::class, MiraiExperimentalAPI::class) + @OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class) final override fun toString(): String } diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt index fe0ff4b4d..a0a317129 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotAccount.kt @@ -52,5 +52,5 @@ data class BotAccount( @MiraiInternalAPI @Retention(AnnotationRetention.SOURCE) @Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR) -@Experimental(level = Experimental.Level.WARNING) +@RequiresOptIn(level = RequiresOptIn.Level.WARNING) annotation class RawAccountIdUse \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt index b1d71b6b4..4103df4bb 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt @@ -27,7 +27,7 @@ import kotlin.coroutines.CoroutineContext /* * 泛型 N 不需要向外(接口)暴露. */ -@UseExperimental(MiraiExperimentalAPI::class) +@OptIn(MiraiExperimentalAPI::class) @MiraiInternalAPI abstract class BotImpl constructor( context: Context, @@ -42,7 +42,8 @@ abstract class BotImpl constructor( @Suppress("CanBePrimaryConstructorProperty") // for logger final override val account: BotAccount = account - @UseExperimental(RawAccountIdUse::class) + + @OptIn(RawAccountIdUse::class) override val uin: Long get() = account.id final override val logger: MiraiLogger by lazy { configuration.botLoggerSupplier(this) } @@ -171,7 +172,7 @@ abstract class BotImpl constructor( // endregion - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) override fun close(cause: Throwable?) { if (!this.botJob.isActive) { // already cancelled diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt index c2a4e1d11..0e8030d3c 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt @@ -36,7 +36,7 @@ import kotlin.jvm.JvmSynthetic * * @author Him188moe */ // 不要删除多平台结构 !!! kotlin bug -@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class) +@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @Suppress("INAPPLICABLE_JVM_NAME") expect abstract class Contact() : CoroutineScope, ContactJavaHappyAPI { /** diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt index 0742c2c90..a1ad294b5 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt @@ -19,7 +19,7 @@ import net.mamoe.mirai.utils.* * * @see ContactList.asSequence */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) @Suppress("unused") class ContactList(@MiraiInternalAPI val delegate: LockFreeLinkedList) { /** @@ -79,7 +79,7 @@ fun ContactList.toList(): List = toMutableList() /** * Collect all the elements into a [MutableList]. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun ContactList.toMutableList(): MutableList = this.delegate.toMutableList() /** @@ -90,7 +90,7 @@ fun ContactList.toSet(): Set = toMutableSet() /** * Collect all the elements into a [MutableSet]. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun ContactList.toMutableSet(): MutableSet = this.delegate.toMutableSet() /** @@ -98,7 +98,7 @@ fun ContactList.toMutableSet(): MutableSet = this.delegate.t * * Note that the sequence is dynamic, that is, elements are yielded atomically only when it is required */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun ContactList.asSequence(): Sequence { return this.delegate.asSequence() } \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt index 9e9c97672..d088d8224 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Member.kt @@ -25,7 +25,7 @@ import kotlin.time.ExperimentalTime * 群成员. */ // 不要删除多平台结构, kotlin bug @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class) +@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) expect abstract class Member() : MemberJavaHappyAPI { /** * 所在的群. diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/MemberPermission.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/MemberPermission.kt index baeb5951f..22dc88a09 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/MemberPermission.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/MemberPermission.kt @@ -82,7 +82,7 @@ expect class PermissionDeniedException : IllegalStateException { * * @throws PermissionDeniedException */ -@UseExperimental(MiraiExperimentalAPI::class) +@OptIn(MiraiExperimentalAPI::class) inline fun Group.checkBotPermission( required: MemberPermission, lazyMessage: () -> String = { @@ -99,7 +99,7 @@ inline fun Group.checkBotPermission( * * @throws PermissionDeniedException */ -@UseExperimental(MiraiExperimentalAPI::class) +@OptIn(MiraiExperimentalAPI::class) inline fun Group.checkBotPermissionOperator( lazyMessage: () -> String = { "Permission denied: required ${MemberPermission.ADMINISTRATOR} or ${MemberPermission.OWNER}, got actual $botPermission for $bot in group $id" diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt index 241656fdc..3ce170194 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt @@ -66,7 +66,7 @@ abstract class AbstractCancellableEvent : Event, CancellableEvent { /** * 广播一个事件的唯一途径. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) suspend fun E.broadcast(): E = apply { if (this is BroadcastControllable && !this.shouldBroadcast) { return@apply diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt index 64a6b9e5e..81c30d1e2 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/BotEvents.kt @@ -143,7 +143,7 @@ sealed class MessageRecallEvent : BotEvent { ) : MessageRecallEvent(), GroupOperableEvent, Packet } -@UseExperimental(MiraiExperimentalAPI::class) +@OptIn(MiraiExperimentalAPI::class) val MessageRecallEvent.GroupRecall.author: Member get() = if (authorId == bot.uin) group.botAsMember else group[authorId] diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/types.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/types.kt index 25b42589f..8acf68fd9 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/types.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/types.kt @@ -73,7 +73,7 @@ val GroupOperableEvent.isByBot: Boolean get() = operator == null * 当操作人为 [Member] 时获取这个 [Member], * 当操作人为 [Bot] 时获取 [Group.botAsMember] */ -@UseExperimental(MiraiExperimentalAPI::class) +@OptIn(MiraiExperimentalAPI::class) val GroupOperableEvent.operatorOrBot: Member get() = this.operator ?: this.group.botAsMember diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt index d3c91df35..1d068c826 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt @@ -36,7 +36,7 @@ internal fun CoroutineScope.Handler( coroutineContext: CoroutineContext, handler: suspend (E) -> ListeningStatus ): Handler { - @UseExperimental(ExperimentalCoroutinesApi::class) // don't remove + @OptIn(ExperimentalCoroutinesApi::class) // don't remove val context = this.newCoroutineContext(coroutineContext) return Handler(context[Job], context, handler) } @@ -50,7 +50,7 @@ internal class Handler @PublishedApi internal constructor(parentJob: Job?, private val subscriberContext: CoroutineContext, @JvmField val handler: suspend (E) -> ListeningStatus) : Listener, CompletableJob by Job(parentJob) { - @UseExperimental(MiraiDebugAPI::class) + @OptIn(MiraiDebugAPI::class) override suspend fun onEvent(event: E): ListeningStatus { if (isCompleted || isCancelled) return ListeningStatus.STOPPED if (!isActive) return ListeningStatus.LISTENING @@ -155,7 +155,7 @@ internal suspend inline fun Event.broadcastInternal() = coroutineScope { } } -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) private fun CoroutineScope.callAndRemoveIfRequired(event: E, listeners: EventListeners) { // atomic foreach listeners.forEachNode { node -> diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt index 1fdc66593..d6cacba04 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt @@ -33,7 +33,7 @@ import kotlin.coroutines.EmptyCoroutineContext * * @see CoroutineScope.incoming */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun CoroutineScope.subscribeMessages( coroutineContext: CoroutineContext = EmptyCoroutineContext, crossinline listeners: MessageSubscribersBuilder>.() -> R @@ -58,7 +58,7 @@ inline fun CoroutineScope.subscribeMessages( * * @see CoroutineScope.incoming */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun CoroutineScope.subscribeGroupMessages( coroutineContext: CoroutineContext = EmptyCoroutineContext, crossinline listeners: MessageSubscribersBuilder.() -> R @@ -78,7 +78,7 @@ inline fun CoroutineScope.subscribeGroupMessages( * * @see CoroutineScope.incoming */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun CoroutineScope.subscribeFriendMessages( coroutineContext: CoroutineContext = EmptyCoroutineContext, crossinline listeners: MessageSubscribersBuilder.() -> R @@ -98,7 +98,7 @@ inline fun CoroutineScope.subscribeFriendMessages( * * @see CoroutineScope.incoming */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun Bot.subscribeMessages( coroutineContext: CoroutineContext = EmptyCoroutineContext, crossinline listeners: MessageSubscribersBuilder>.() -> R @@ -120,7 +120,7 @@ inline fun Bot.subscribeMessages( * * @see CoroutineScope.incoming */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun Bot.subscribeGroupMessages( coroutineContext: CoroutineContext = EmptyCoroutineContext, crossinline listeners: MessageSubscribersBuilder.() -> R @@ -140,7 +140,7 @@ inline fun Bot.subscribeGroupMessages( * * @see CoroutineScope.incoming */ -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun Bot.subscribeFriendMessages( coroutineContext: CoroutineContext = EmptyCoroutineContext, crossinline listeners: MessageSubscribersBuilder.() -> R diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt index 9470f7005..c652d88d5 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt @@ -118,7 +118,7 @@ interface Listener : CompletableJob { * @see subscribeGroupMessages 监听群消息 DSL * @see subscribeFriendMessages 监听好友消息 DSL */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) inline fun CoroutineScope.subscribe( coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline handler: suspend E.(E) -> ListeningStatus @@ -136,7 +136,7 @@ inline fun CoroutineScope.subscribe( * * @see subscribe 获取更多说明 */ -@UseExperimental(MiraiInternalAPI::class, ExperimentalContracts::class) +@OptIn(MiraiInternalAPI::class, ExperimentalContracts::class) inline fun CoroutineScope.subscribeAlways( coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline listener: suspend E.(E) -> Unit @@ -158,7 +158,7 @@ inline fun CoroutineScope.subscribeAlways( * * @see subscribe 获取更多说明 */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) inline fun CoroutineScope.subscribeOnce( coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline listener: suspend E.(E) -> Unit @@ -184,7 +184,7 @@ inline fun CoroutineScope.subscribeOnce( * @see subscribe 获取更多说明 */ @JvmName("subscribeAlwaysForBot") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) inline fun Bot.subscribe( coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline handler: suspend E.(E) -> ListeningStatus @@ -204,7 +204,7 @@ inline fun Bot.subscribe( * @see subscribe 获取更多说明 */ @JvmName("subscribeAlwaysForBot1") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) inline fun Bot.subscribeAlways( coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline listener: suspend E.(E) -> Unit @@ -224,7 +224,7 @@ inline fun Bot.subscribeAlways( * @see subscribe 获取更多说明 */ @JvmName("subscribeOnceForBot2") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) inline fun Bot.subscribeOnce( coroutineContext: CoroutineContext = EmptyCoroutineContext, noinline listener: suspend E.(E) -> Unit diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/javaHappy.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/javaHappy.kt index d3e9f581f..31de9e48c 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/javaHappy.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/javaHappy.kt @@ -15,7 +15,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI * 表明这个 API 是为了让 Java 使用者调用更方便. */ @MiraiInternalAPI -@Experimental(level = Experimental.Level.ERROR) +@RequiresOptIn(level = RequiresOptIn.Level.ERROR) @Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.CLASS) annotation class JavaHappyAPI diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt index 0940819a6..553e09619 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt @@ -25,7 +25,7 @@ import net.mamoe.mirai.utils.WeakRef * 使用低级的 API 无法带来任何安全和便捷保障. * 仅在某些使用结构化 API 可能影响性能的情况下使用这些低级 API. */ -@Experimental +@RequiresOptIn @Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) annotation class LowLevelAPI diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt index 492c654ac..dadce1730 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessagePacket.kt @@ -33,7 +33,7 @@ import kotlin.jvm.JvmName * 一条从服务器接收到的消息事件. * 请查看各平台的 `actual` 实现的说明. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) expect abstract class MessagePacket() : MessagePacketBase /** diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt index c9204ab0d..73d8f5c9c 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/At.kt @@ -28,6 +28,7 @@ import kotlin.jvm.JvmStatic * @see AtAll 全体成员 */ class At +@Suppress("MemberVisibilityCanBePrivate") private constructor(val target: Long, val display: String) : Message, MessageContent { /** diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt index 32a7dd04d..dc78d752c 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt @@ -76,7 +76,7 @@ interface OnlineImage : Image { * 查询原图下载链接. */ suspend fun Image.queryUrl(): String { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) return when (this) { is OnlineImage -> this.originUrl else -> BotImpl.instances.peekFirst().get()?.queryImageUrl(this) @@ -102,7 +102,7 @@ interface OfflineImage : Image * 原图下载链接. 包含域名 */ suspend fun OfflineImage.queryOriginUrl(): String { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) return BotImpl.instances.peekFirst().get()?.queryImageUrl(this) ?: error("No Bot available to query image url") } @@ -115,7 +115,7 @@ suspend fun OfflineImage.queryOriginUrl(): String { * 群图片 */ // CustomFace -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) sealed class GroupImage : AbstractImage() { abstract val filepath: String abstract val fileId: Int @@ -184,7 +184,7 @@ abstract class OnlineGroupImage : GroupImage(), OnlineImage /** * 好友图片 */ // NotOnlineImage -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) sealed class FriendImage : AbstractImage() { abstract val resourceId: String abstract val md5: ByteArray diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt index f0426083c..b23371bf6 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/QuoteReply.kt @@ -39,7 +39,7 @@ open class QuoteReply * 用于发送的引用回复. * 总是使用 [quote] 来构造实例. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) sealed class QuoteReplyToSend @MiraiInternalAPI constructor(source: MessageSource) : QuoteReply(source) { class ToGroup(source: MessageSource, val sender: QQ) : QuoteReplyToSend(source) { @@ -53,7 +53,7 @@ sealed class QuoteReplyToSend * 引用这条消息. * @see sender 消息发送人. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun MessageChain.quote(sender: QQ?): QuoteReplyToSend { this.firstOrNull()?.let { return it.quote(sender) @@ -65,7 +65,7 @@ fun MessageChain.quote(sender: QQ?): QuoteReplyToSend { * 引用这条消息. * @see from 消息来源. 若是好友发送 */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun MessageSource.quote(from: QQ?): QuoteReplyToSend { return if (this.groupId != 0L) { check(from is Member) { "sender must be Member to quote a GroupMessage" } diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt index b2f36d33b..01edbd102 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/BotNetworkHandler.kt @@ -101,7 +101,7 @@ abstract class BotNetworkHandler : CoroutineScope { } } -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) suspend fun BotNetworkHandler.closeAndJoin(cause: Throwable? = null) { this.close(cause) this.supervisor.join() diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt index cf911eff2..340e392df 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/DeviceInfo.kt @@ -120,7 +120,7 @@ class DeviceInfoData( @Transient override lateinit var context: Context - @UseExperimental(ExperimentalUnsignedTypes::class) + @OptIn(ExperimentalUnsignedTypes::class) override val ipAddress: ByteArray get() = localIpAddress().split(".").map { it.toUByte().toByte() }.takeIf { it.size == 4 }?.toByteArray() ?: byteArrayOf() override val androidId: ByteArray get() = display diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/annotataions.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/annotataions.kt index 26f395deb..60411fdb3 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/annotataions.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/annotataions.kt @@ -18,7 +18,7 @@ import kotlin.annotation.AnnotationTarget.* * 非常不建议在发行版本中使用这些 API. */ @Retention(AnnotationRetention.BINARY) -@Experimental(level = Experimental.Level.ERROR) +@RequiresOptIn(level = RequiresOptIn.Level.ERROR) @Target( CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR, CLASS, @@ -36,7 +36,7 @@ annotation class MiraiInternalAPI( * 不建议在发行版本中使用这些 API. */ @Retention(AnnotationRetention.BINARY) -@Experimental(level = Experimental.Level.WARNING) +@RequiresOptIn(level = RequiresOptIn.Level.WARNING) @Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR) annotation class MiraiExperimentalAPI( val message: String = "" @@ -49,7 +49,7 @@ annotation class MiraiExperimentalAPI( * 非常不建议在发行版本中使用这些 API. */ @Retention(AnnotationRetention.BINARY) -@Experimental(level = Experimental.Level.WARNING) +@RequiresOptIn(level = RequiresOptIn.Level.WARNING) @Target(CLASS, TYPEALIAS, FUNCTION, PROPERTY, FIELD, CONSTRUCTOR) annotation class MiraiDebugAPI( val message: String = "" diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/channels.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/channels.kt index cc0bcfef3..fd80f788c 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/channels.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/channels.kt @@ -30,7 +30,7 @@ import kotlin.jvm.JvmName * 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst] */ suspend fun ByteReadChannel.copyTo(dst: OutputStream) { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) ByteArrayPool.useInstance { buffer -> var size: Int while (this.readAvailable(buffer).also { size = it } > 0) { @@ -43,7 +43,7 @@ suspend fun ByteReadChannel.copyTo(dst: OutputStream) { * 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst] */ suspend fun ByteReadChannel.copyTo(dst: Output) { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) ByteArrayPool.useInstance { buffer -> var size: Int while (this.readAvailable(buffer).also { size = it } > 0) { @@ -75,7 +75,7 @@ suspend fun ByteReadChannel.copyTo(dst: kotlinx.coroutines.io.ByteWriteChannel) */ suspend fun ByteReadChannel.copyAndClose(dst: OutputStream) { try { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) ByteArrayPool.useInstance { buffer -> var size: Int while (this.readAvailable(buffer).also { size = it } > 0) { @@ -92,7 +92,7 @@ suspend fun ByteReadChannel.copyAndClose(dst: OutputStream) { */ suspend fun ByteReadChannel.copyAndClose(dst: Output) { try { - @UseExperimental(MiraiInternalAPI::class) + @OptIn(MiraiInternalAPI::class) ByteArrayPool.useInstance { buffer -> var size: Int while (this.readAvailable(buffer).also { size = it } > 0) { diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/byteArrays.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/byteArrays.kt index 970a71a7d..602aaef85 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/byteArrays.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/byteArrays.kt @@ -30,7 +30,7 @@ import kotlin.jvm.JvmSynthetic @JvmOverloads @Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) fun List.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String { require(offset >= 0) { "offset shouldn't be negative: $offset" } require(length >= 0) { "length shouldn't be negative: $length" } @@ -54,7 +54,7 @@ fun List.toUHexString(separator: String = " ", offset: Int = 0, length: In @JvmOverloads @Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String { this.checkOffsetAndLength(offset, length) if (length == 0) { @@ -99,7 +99,7 @@ inline fun ByteArray.encodeToString(charset: Charset = Charsets.UTF_8): String = inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset) = ByteReadPacket(this, offset = offset, length = length) -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun ByteArray.read(t: ByteReadPacket.() -> R): R { contract { callsInPlace(t, InvocationKind.EXACTLY_ONCE) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/chunked.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/chunked.kt index e9c3a0dfc..baa9ff335 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/chunked.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/chunked.kt @@ -51,7 +51,7 @@ class ChunkedInput( * * 若 [ByteReadPacket.remaining] 小于 [sizePerPacket], 将会返回唯一元素 [this] 的 [Sequence] */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun ByteReadPacket.chunkedFlow(sizePerPacket: Int): Flow { ByteArrayPool.checkBufferSize(sizePerPacket) if (this.remaining <= sizePerPacket.toLong()) { @@ -76,7 +76,7 @@ fun ByteReadPacket.chunkedFlow(sizePerPacket: Int): Flow { * 对于一个 1000 长度的 [ByteReadChannel] 和参数 [sizePerPacket] = 300, 将会产生含四个元素的 [Sequence], * 其长度分别为: 300, 300, 300, 100. */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun ByteReadChannel.chunkedFlow(sizePerPacket: Int): Flow { ByteArrayPool.checkBufferSize(sizePerPacket) if (this.isClosedForRead) { @@ -100,7 +100,7 @@ fun ByteReadChannel.chunkedFlow(sizePerPacket: Int): Flow { * 对于一个 1000 长度的 [Input] 和参数 [sizePerPacket] = 300, 将会产生含四个元素的 [Sequence], * 其长度分别为: 300, 300, 300, 100. */ -@UseExperimental(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class) +@OptIn(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class) internal fun Input.chunkedFlow(sizePerPacket: Int): Flow { ByteArrayPool.checkBufferSize(sizePerPacket) @@ -127,7 +127,7 @@ internal fun Input.chunkedFlow(sizePerPacket: Int): Flow { * * 若 [ByteReadPacket.remaining] 小于 [sizePerPacket], 将会返回唯一元素 [this] 的 [Sequence] */ -@UseExperimental(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class) +@OptIn(MiraiInternalAPI::class, ExperimentalCoroutinesApi::class) internal fun InputStream.chunkedFlow(sizePerPacket: Int): Flow { ByteArrayPool.checkBufferSize(sizePerPacket) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/input.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/input.kt index 235805342..ea495bee6 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/input.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/input.kt @@ -27,7 +27,7 @@ import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName import kotlin.jvm.JvmSynthetic -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) fun ByteReadPacket.copyTo(outputStream: OutputStream) { ByteArrayPool.useInstance { while (this.isNotEmpty) { @@ -50,7 +50,7 @@ inline fun ByteReadPacket.readPacketExact( n: Int = remaining.toInt()//not that safe but adequate ): ByteReadPacket = this.readBytes(n).toReadPacket() -@UseExperimental(ExperimentalContracts::class) +@OptIn(ExperimentalContracts::class) inline fun C.withUse(block: C.() -> R): R { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt index 837541e2a..a5cd1f891 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/output.kt @@ -68,6 +68,6 @@ fun BytePacketBuilder.writeHex(uHex: String) { /** * 会使用 [ByteArrayPool] 缓存 */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) inline fun BytePacketBuilder.encryptAndWrite(key: ByteArray, encoder: BytePacketBuilder.() -> Unit) = TEA.encrypt(BytePacketBuilder().apply(encoder).build(), key) { decrypted -> writeFully(decrypted) } \ No newline at end of file diff --git a/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.message.data/CombinedMessageTest.kt b/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.message.data/CombinedMessageTest.kt index 54b3f067f..04ad0249b 100644 --- a/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.message.data/CombinedMessageTest.kt +++ b/mirai-core/src/commonTest/kotlin/net.mamoe.mirai.message.data/CombinedMessageTest.kt @@ -35,7 +35,7 @@ internal class CombinedMessageTest { private val toAdd = "1".toMessage() - @UseExperimental(ExperimentalTime::class) + @OptIn(ExperimentalTime::class) @Test fun speedTest() = repeat(100) { var count = 1L @@ -86,7 +86,7 @@ internal class CombinedMessageTest { } } - @UseExperimental(ExperimentalTime::class) + @OptIn(ExperimentalTime::class) @Test fun testFastIteration() { println("start!") diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt index 509ed8381..d2b135e2f 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt @@ -24,7 +24,9 @@ import net.mamoe.mirai.utils.* * @see kotlinx.coroutines.isActive 判断 [Bot] 是否正常运行中. (在线, 且没有被 [close]) */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class) +@OptIn( + MiraiInternalAPI::class, LowLevelAPI::class, MiraiExperimentalAPI::class, JavaHappyAPI::class +) actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIAccessor, BotJavaHappyAPI() { actual companion object { /** @@ -244,6 +246,6 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA */ actual abstract fun close(cause: Throwable?) - @UseExperimental(LowLevelAPI::class, MiraiExperimentalAPI::class) + @OptIn(LowLevelAPI::class, MiraiExperimentalAPI::class) actual final override fun toString(): String = "Bot(${uin})" } \ No newline at end of file diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt index c385781dd..5f77238e9 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/BotJavaHappyAPI.kt @@ -132,7 +132,7 @@ actual abstract class BotJavaHappyAPI actual constructor() { message: String? = null, remark: String? = null ): AddFriendResult { - @UseExperimental(MiraiExperimentalAPI::class) + @OptIn(MiraiExperimentalAPI::class) return runBlocking { addFriend(id, message, remark) } } @@ -169,7 +169,7 @@ actual abstract class BotJavaHappyAPI actual constructor() { } } -@UseExperimental(ExperimentalCoroutinesApi::class) +@OptIn(ExperimentalCoroutinesApi::class) internal fun C.future(block: suspend C.() -> R): Future { val future = object : Future { val value: CompletableDeferred = CompletableDeferred() @@ -214,7 +214,7 @@ internal fun C.future(block: suspend C.() -> R): Future< } launch { - @UseExperimental(ExperimentalCoroutinesApi::class) + @OptIn(ExperimentalCoroutinesApi::class) future.value.completeWith(kotlin.runCatching { block() }) } diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt index 174266426..dc0dca721 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Contact.kt @@ -32,7 +32,7 @@ import net.mamoe.mirai.utils.WeakRefProperty * @author Him188moe */ @Suppress("INAPPLICABLE_JVM_NAME") -@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class) +@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) actual abstract class Contact : CoroutineScope, ContactJavaHappyAPI() { /** * 这个联系人所属 [Bot]. diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Member.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Member.kt index 3adc75bc3..adaeeed5e 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Member.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/contact/Member.kt @@ -20,7 +20,7 @@ import net.mamoe.mirai.utils.WeakRefProperty /** * 群成员. */ -@UseExperimental(MiraiInternalAPI::class, JavaHappyAPI::class) +@OptIn(MiraiInternalAPI::class, JavaHappyAPI::class) @Suppress("INAPPLICABLE_JVM_NAME") actual abstract class Member : MemberJavaHappyAPI() { /** diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt index 60faf7d90..027f1dd12 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessagePacket.kt @@ -29,7 +29,7 @@ import java.net.URL * 一条从服务器接收到的消息事件. * JVM 平台相关扩展 */ -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual abstract class MessagePacket actual constructor() : MessagePacketBase() { // region 上传图片 suspend inline fun uploadImage(image: BufferedImage): Image = subject.uploadImage(image) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt index 3d708e3ed..49755320a 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/MessageReceipt.kt @@ -28,7 +28,7 @@ import net.mamoe.mirai.utils.unsafeWeakRef * @see MessageReceipt.sourceTime 源时间 */ @Suppress("FunctionName") -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual open class MessageReceipt actual constructor( actual val source: MessageSource, target: C, @@ -94,7 +94,7 @@ actual open class MessageReceipt actual constructor( */ actual open suspend fun quote(): QuoteReplyToSend { this.source.ensureSequenceIdAvailable() - @UseExperimental(LowLevelAPI::class) + @OptIn(LowLevelAPI::class) return _unsafeQuote() } diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt index 49472129a..e9aa2024c 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt @@ -57,7 +57,7 @@ actual fun localIpAddress(): String = InetAddress.getLocalHost().hostAddress actual val Http: HttpClient get() = HttpClient(CIO) -@UseExperimental(MiraiInternalAPI::class) +@OptIn(MiraiInternalAPI::class) actual fun ByteArray.unzip(offset: Int, length: Int): ByteArray { this.checkOffsetAndLength(offset, length) if (length == 0) return ByteArray(0) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt index e71cbbfdd..52e5accf0 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/SystemDeviceInfo.kt @@ -21,7 +21,7 @@ import java.io.File /** * 加载一个设备信息. 若文件不存在或为空则随机并创建一个设备信息保存. */ -@UseExperimental(UnstableDefault::class) +@OptIn(UnstableDefault::class) fun File.loadAsDeviceInfo(context: Context = ContextImpl()): DeviceInfo { if (!this.exists() || this.length() == 0L) { return SystemDeviceInfo(context).also { @@ -35,7 +35,7 @@ fun File.loadAsDeviceInfo(context: Context = ContextImpl()): DeviceInfo { @Serializable -@UseExperimental(ExperimentalUnsignedTypes::class) +@OptIn(ExperimentalUnsignedTypes::class) actual open class SystemDeviceInfo actual constructor() : DeviceInfo() { actual constructor(context: Context) : this() { this.context = context diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt index 063565c1d..f6859e6c7 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/io/PlatformSocket.kt @@ -80,7 +80,7 @@ actual class PlatformSocket : Closeable { } } - @UseExperimental(ExperimentalIoApi::class) + @OptIn(ExperimentalIoApi::class) actual suspend fun connect(serverHost: String, serverPort: Int) { withContext(Dispatchers.IO) { socket = Socket(serverHost, serverPort) diff --git a/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt index 6af63aa89..ea206952d 100644 --- a/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt +++ b/mirai-core/src/jvmTest/kotlin/net/mamoe/mirai/utils/LockFreeLinkedListTest.kt @@ -142,7 +142,7 @@ internal class LockFreeLinkedListTest { list.size shouldBeEqualTo 0 } - @UseExperimental(ExperimentalUnsignedTypes::class) + @OptIn(ExperimentalUnsignedTypes::class) @Test fun withInlineClassElements() { val list = LockFreeLinkedList() @@ -270,7 +270,7 @@ internal class LockFreeLinkedListTest { */ } -@UseExperimental(ExperimentalCoroutinesApi::class) +@OptIn(ExperimentalCoroutinesApi::class) @MiraiExperimentalAPI internal suspend inline fun > E.concurrentDo(numberOfCoroutines: Int, times: Int, crossinline todo: E.() -> Unit) = coroutineScope {