From 37344c19d604e224b0c12e03d67f9380ec0f2931 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 6 Mar 2020 22:04:55 +0800 Subject: [PATCH] Fix addSuppressed --- .../kotlin/net/mamoe/mirai/utils/addSuppressed.kt | 5 ++--- .../kotlin/net.mamoe.mirai/utils/tryNTimes.kt | 11 +++++------ .../kotlin/net/mamoe/mirai/utils/addSuppressed.kt | 5 ++--- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt index 6cf9bfd8d..fb52beebe 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt @@ -4,9 +4,8 @@ import android.os.Build private var isAddSuppressedSupported: Boolean = true -@MiraiInternalAPI -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -actual fun Throwable.addSuppressed(e: Throwable) { +@PublishedApi +internal actual fun Throwable.addSuppressedMirai(e: Throwable) { if (this === e) { return } diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt index c6b6884d0..b336967f7 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/tryNTimes.kt @@ -9,9 +9,8 @@ package net.mamoe.mirai.utils -@MiraiInternalAPI -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -expect fun Throwable.addSuppressed(e: Throwable) +@PublishedApi +internal expect fun Throwable.addSuppressedMirai(e: Throwable) @MiraiInternalAPI @Suppress("DuplicatedCode") @@ -24,7 +23,7 @@ inline fun tryNTimes(repeat: Int, block: (Int) -> R): R { } catch (e: Throwable) { if (lastException == null) { lastException = e - } else lastException!!.addSuppressed(e) + } else lastException!!.addSuppressedMirai(e) } } @@ -42,7 +41,7 @@ inline fun tryNTimesOrNull(repeat: Int, block: (Int) -> R): R? { } catch (e: Throwable) { if (lastException == null) { lastException = e - } else lastException!!.addSuppressed(e) + } else lastException!!.addSuppressedMirai(e) } } @@ -61,7 +60,7 @@ inline fun tryNTimesOrException(repeat: Int, block: (Int) -> R): Throwable? } catch (e: Throwable) { if (lastException == null) { lastException = e - } else lastException!!.addSuppressed(e) + } else lastException!!.addSuppressedMirai(e) } } diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt index dc3a97703..797402a7c 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/addSuppressed.kt @@ -2,9 +2,8 @@ package net.mamoe.mirai.utils private var isAddSuppressedSupported: Boolean = true -@MiraiInternalAPI -@Suppress("EXTENSION_SHADOWED_BY_MEMBER") -actual fun Throwable.addSuppressed(e: Throwable) { +@PublishedApi +internal actual fun Throwable.addSuppressedMirai(e: Throwable) { if (this === e) { return }