mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-25 13:03:35 +08:00
[core] Fix minor compiler warnings
- unused variables - requires opt-in
This commit is contained in:
parent
3cbc253121
commit
d2d2f4844d
mirai-core-utils/src/jvmBaseMain/kotlin
mirai-core/src
commonMain/kotlin
message
network/auth
jvmBaseMain/kotlin/message/protocol/impl
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
* Copyright 2019-2023 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
@ -56,7 +56,7 @@ public actual fun <T : Any> loadService(clazz: KClass<out T>, fallbackImplementa
|
||||
|
||||
return Services.getOverrideOrNull(clazz) ?: services
|
||||
?: throw NoSuchElementException("Could not find an implementation for service class ${clazz.qualifiedName}").apply {
|
||||
if (suppressed != null) addSuppressed(suppressed)
|
||||
if (suppressed != null) addSuppressed(suppressed!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
* Copyright 2019-2023 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
@ -18,4 +18,5 @@ public fun <T : Any?> threadLocal(newInstance: () -> T): ThreadLocal<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public operator fun <T> ThreadLocal<T>.getValue(t: Any?, property: KProperty<Any?>): T = this.get()
|
||||
public operator fun <T> ThreadLocal<T>.getValue(t: Any?, property: KProperty<Any?>): T =
|
||||
this.get() as T // `get()` is from Java and has type of `T!`
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
* Copyright 2019-2023 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
@ -73,7 +73,7 @@ internal class GeneralMessageSenderProtocol : MessageProtocol(PRIORITY_GENERAL_S
|
||||
|
||||
// Patch time to be actual server time
|
||||
var finalTime = bot.clock.server.currentTimeSeconds().toInt()
|
||||
val sendPacketOk = sendAllPackets(bot, step, contact, packets) { idx, rsp ->
|
||||
val sendPacketOk = sendAllPackets(bot, step, contact, packets) { _, rsp ->
|
||||
if (rsp is MessageSvcPbSendMsg.Response.SUCCESS) {
|
||||
finalTime = rsp.sendTime
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
* Copyright 2019-2023 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
@ -96,7 +96,7 @@ internal class OnlineMessageSourceFromFriendImpl(
|
||||
}
|
||||
|
||||
|
||||
private val jceData: ImMsgBody.SourceMsg by lazy { msg.toJceDataPrivate(internalIds) }
|
||||
private val jceData: ImMsgBody.SourceMsg by lazy { msg.toJceDataPrivate() }
|
||||
|
||||
override fun toJceData(): ImMsgBody.SourceMsg = jceData
|
||||
|
||||
@ -161,7 +161,7 @@ internal class OnlineMessageSourceFromStrangerImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private val jceData: ImMsgBody.SourceMsg by lazy { msg.toJceDataPrivate(internalIds) }
|
||||
private val jceData: ImMsgBody.SourceMsg by lazy { msg.toJceDataPrivate() }
|
||||
|
||||
override fun toJceData(): ImMsgBody.SourceMsg = jceData
|
||||
|
||||
@ -170,7 +170,7 @@ internal class OnlineMessageSourceFromStrangerImpl(
|
||||
}
|
||||
}
|
||||
|
||||
private fun List<MsgComm.Msg>.toJceDataPrivate(ids: IntArray): ImMsgBody.SourceMsg {
|
||||
private fun List<MsgComm.Msg>.toJceDataPrivate(): ImMsgBody.SourceMsg {
|
||||
val elements = flatMap { it.msgBody.richText.elems }.toMutableList().also {
|
||||
if (it.lastOrNull()?.elemFlags2 == null) it.add(ImMsgBody.Elem(elemFlags2 = ImMsgBody.ElemFlags2()))
|
||||
}
|
||||
@ -279,7 +279,7 @@ internal class OnlineMessageSourceFromTempImpl(
|
||||
get() = msg.first().msgHead.toUin
|
||||
|
||||
|
||||
private val jceData: ImMsgBody.SourceMsg by lazy { msg.toJceDataPrivate(internalIds) }
|
||||
private val jceData: ImMsgBody.SourceMsg by lazy { msg.toJceDataPrivate() }
|
||||
override fun toJceData(): ImMsgBody.SourceMsg = jceData
|
||||
|
||||
override fun <D, R> accept(visitor: MessageVisitor<D, R>, data: D): R {
|
||||
|
@ -11,6 +11,7 @@ package net.mamoe.mirai.internal.network.auth
|
||||
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
/**
|
||||
@ -133,6 +134,7 @@ internal sealed interface ProducerState<T, V> {
|
||||
val producerLatch = Latch<T>(parentCoroutineContext)
|
||||
|
||||
override fun toString(): String {
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
val completed =
|
||||
value.runCatching { getCompleted().toString() }.getOrNull() // getCompleted() is experimental
|
||||
return "Consuming(value=$completed)"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
* Copyright 2019-2023 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
@ -10,6 +10,6 @@
|
||||
package net.mamoe.mirai.internal.message.protocol.impl
|
||||
|
||||
internal actual fun getEmojiPatternResourceOrNull(): String? {
|
||||
return TextProtocol::class.java.classLoader.getResourceAsStream("emoji-pattern.regex")
|
||||
return TextProtocol::class.java.classLoader?.getResourceAsStream("emoji-pattern.regex")
|
||||
?.use { it.readBytes().decodeToString() }
|
||||
}
|
Loading…
Reference in New Issue
Block a user