From c5d98cbefda6893934e65923108901f8464077d8 Mon Sep 17 00:00:00 2001
From: Him188 <Him188@mamoe.net>
Date: Sun, 8 Mar 2020 00:44:43 +0800
Subject: [PATCH] Replace use of `Experimental` with `OptIn`

---
 .../kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt        | 4 ++--
 .../kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt        | 2 +-
 .../kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt        | 4 ++--
 mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt | 2 +-
 .../src/commonMain/kotlin/net.mamoe.mirai/javaHappy.kt      | 2 +-
 .../src/commonMain/kotlin/net.mamoe.mirai/utils/channels.kt | 6 +++---
 6 files changed, 10 insertions(+), 10 deletions(-)

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 044a7cd9b..8f85846b3 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
@@ -32,7 +32,7 @@ actual constructor(
     configuration: BotConfiguration
 ) : QQAndroidBotBase(context, account, configuration)
 
-@UseExperimental(MiraiInternalAPI::class)
+@OptIn(MiraiInternalAPI::class)
 @Suppress("DEPRECATION")
 internal actual fun ByteReadChannel.toKotlinByteReadChannel(): kotlinx.coroutines.io.ByteReadChannel {
     return object : kotlinx.coroutines.io.ByteReadChannel {
@@ -144,7 +144,7 @@ internal actual fun ByteReadChannel.toKotlinByteReadChannel(): kotlinx.coroutine
             return this@toKotlinByteReadChannel.readRemaining(limit, headerSizeHint).readBytes().toReadPacket()
         }
 
-        @UseExperimental(ExperimentalIoApi::class)
+        @OptIn(ExperimentalIoApi::class)
         @ExperimentalIoApi
         override fun readSession(consumer: ReadSession.() -> Unit) {
             @Suppress("DEPRECATION")
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 0e7c0bd46..af7b7b02f 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
@@ -227,5 +227,5 @@ internal abstract class QQAndroidBotBase constructor(
 }
 
 @Suppress("DEPRECATION")
-@UseExperimental(MiraiInternalAPI::class)
+@OptIn(MiraiInternalAPI::class)
 internal expect fun io.ktor.utils.io.ByteReadChannel.toKotlinByteReadChannel(): ByteReadChannel
\ No newline at end of file
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 886581f6e..041f10968 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
@@ -37,7 +37,7 @@ internal actual class QQAndroidBot actual constructor(
     configuration: BotConfiguration
 ) : QQAndroidBotBase(context, account, configuration)
 
-@UseExperimental(MiraiInternalAPI::class)
+@OptIn(MiraiInternalAPI::class)
 @Suppress("DEPRECATION")
 internal actual fun ByteReadChannel.toKotlinByteReadChannel(): kotlinx.coroutines.io.ByteReadChannel {
     return object : kotlinx.coroutines.io.ByteReadChannel {
@@ -145,7 +145,7 @@ internal actual fun ByteReadChannel.toKotlinByteReadChannel(): kotlinx.coroutine
             return this@toKotlinByteReadChannel.readRemaining(limit, headerSizeHint).readBytes().toReadPacket()
         }
 
-        @UseExperimental(ExperimentalIoApi::class)
+        @OptIn(ExperimentalIoApi::class)
         @ExperimentalIoApi
         override fun readSession(consumer: ReadSession.() -> Unit) {
             @Suppress("DEPRECATION")
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 7d8e4c894..4abf3541c 100644
--- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
+++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotImpl.kt
@@ -40,7 +40,7 @@ abstract class BotImpl<N : BotNetworkHandler> constructor(
             ?: CoroutineExceptionHandler { _, e -> logger.error("An exception was thrown under a coroutine of Bot", e) })
     override val context: Context by context.unsafeWeakRef()
 
-    @UseExperimental(LowLevelAPI::class)
+    @OptIn(LowLevelAPI::class)
     @Suppress("CanBePrimaryConstructorProperty", "OverridingDeprecatedMember") // for logger
     final override val account: BotAccount = account
 
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/utils/channels.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/channels.kt
index 3d93f3593..f0495774a 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
@@ -58,7 +58,7 @@ suspend fun ByteReadChannel.copyTo(dst: Output) {
  * 从接收者管道读取所有数据并写入 [dst]. 不会关闭 [dst]
  */
 suspend fun ByteReadChannel.copyTo(dst: ByteWriteChannel) {
-    @UseExperimental(MiraiInternalAPI::class)
+    @OptIn(MiraiInternalAPI::class)
     ByteArrayPool.useInstance { buffer ->
         var size: Int
         while (this.readAvailable(buffer).also { size = it } > 0) {
@@ -126,7 +126,7 @@ suspend fun ByteReadChannel.copyAndClose(dst: Output) {
 suspend fun ByteReadChannel.copyAndClose(dst: ByteWriteChannel) {
     @Suppress("DuplicatedCode")
     try {
-        @UseExperimental(MiraiInternalAPI::class)
+        @OptIn(MiraiInternalAPI::class)
         ByteArrayPool.useInstance { buffer ->
             var size: Int
             while (this.readAvailable(buffer).also { size = it } > 0) {
@@ -145,7 +145,7 @@ suspend fun ByteReadChannel.copyAndClose(dst: ByteWriteChannel) {
 suspend fun ByteReadChannel.copyAndClose(dst: io.ktor.utils.io.ByteWriteChannel) {
     @Suppress("DuplicatedCode")
     try {
-        @UseExperimental(MiraiInternalAPI::class)
+        @OptIn(MiraiInternalAPI::class)
         ByteArrayPool.useInstance { buffer ->
             var size: Int
             while (this.readAvailable(buffer).also { size = it } > 0) {