Commit d8ef80ea authored by Him188's avatar Him188

Adjust visibility

parent 2295e832
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
@file:Suppress( @file:Suppress(
"MemberVisibilityCanBePrivate", "unused", "EXPERIMENTAL_API_USAGE", "MemberVisibilityCanBePrivate", "unused", "EXPERIMENTAL_API_USAGE",
"NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE" "NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE",
"INAPPLICABLE_JVM_NAME", "WRONG_MODIFIER_CONTAINING_DECLARATION"
) )
@file:JvmMultifileClass @file:JvmMultifileClass
@file:JvmName("MessageUtils") @file:JvmName("MessageUtils")
...@@ -23,10 +24,9 @@ import net.mamoe.mirai.contact.Contact ...@@ -23,10 +24,9 @@ import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.message.MessageEvent import net.mamoe.mirai.message.MessageEvent
import net.mamoe.mirai.message.MessageReceipt import net.mamoe.mirai.message.MessageReceipt
import net.mamoe.mirai.message.data.Message.Key import net.mamoe.mirai.message.data.Message.Key
import net.mamoe.mirai.utils.MiraiExperimentalAPI
import net.mamoe.mirai.utils.PlannedRemoval import net.mamoe.mirai.utils.PlannedRemoval
import kotlin.contracts.contract import kotlin.contracts.contract
import kotlin.internal.HidesMembers
import kotlin.internal.LowPriorityInOverloadResolution
import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmMultifileClass
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
import kotlin.jvm.JvmSynthetic import kotlin.jvm.JvmSynthetic
...@@ -166,7 +166,8 @@ interface Message { // must be interface. Don't consider any changes. ...@@ -166,7 +166,8 @@ interface Message { // must be interface. Don't consider any changes.
* *
* @sample net.mamoe.mirai.message.data.ContentEqualsTest * @sample net.mamoe.mirai.message.data.ContentEqualsTest
*/ */
fun contentEquals(another: Message, ignoreCase: Boolean = false): Boolean = contentEqualsImpl(another, ignoreCase) final fun contentEquals(another: Message, ignoreCase: Boolean = false): Boolean =
contentEqualsImpl(another, ignoreCase)
/** /**
* 判断内容是否与 [another] 相等. * 判断内容是否与 [another] 相等.
...@@ -177,7 +178,7 @@ interface Message { // must be interface. Don't consider any changes. ...@@ -177,7 +178,7 @@ interface Message { // must be interface. Don't consider any changes.
* *
* @sample net.mamoe.mirai.message.data.ContentEqualsTest * @sample net.mamoe.mirai.message.data.ContentEqualsTest
*/ */
fun contentEquals(another: String, ignoreCase: Boolean = false): Boolean { final fun contentEquals(another: String, ignoreCase: Boolean = false): Boolean {
if (!this.contentToString().equals(another, ignoreCase = ignoreCase)) return false if (!this.contentToString().equals(another, ignoreCase = ignoreCase)) return false
return when (this) { return when (this) {
is SingleMessage -> true is SingleMessage -> true
...@@ -186,70 +187,25 @@ interface Message { // must be interface. Don't consider any changes. ...@@ -186,70 +187,25 @@ interface Message { // must be interface. Don't consider any changes.
} }
} }
@LowPriorityInOverloadResolution final operator fun plus(another: MessageChain): MessageChain = this + another as Message
@PlannedRemoval("1.2.0") final operator fun plus(another: Message): MessageChain = this.followedBy(another)
@JvmSynthetic final operator fun plus(another: SingleMessage): MessageChain = this.followedBy(another)
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN) final operator fun plus(another: String): MessageChain = this.followedBy(another.toMessage())
operator fun plus(another: Message): MessageChain = this.followedBy(another) final operator fun plus(another: CharSequence): MessageChain = this.followedBy(another.toString().toMessage())
final operator fun plus(another: Iterable<Message>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
@PlannedRemoval("1.2.0") @JvmName("plusIterableString")
@LowPriorityInOverloadResolution final operator fun plus(another: Iterable<String>): MessageChain =
@JvmSynthetic another.fold(this, Message::plus).asMessageChain()
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
operator fun plus(another: SingleMessage): MessageChain = this.followedBy(another)
@PlannedRemoval("1.2.0") final operator fun plus(another: Sequence<Message>): MessageChain =
@JvmSynthetic another.fold(this, Message::plus).asMessageChain()
@LowPriorityInOverloadResolution // won't be resolved
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
operator fun plus(another: String): MessageChain = this.followedBy(another.toMessage())
@PlannedRemoval("1.2.0")
@LowPriorityInOverloadResolution
@JvmSynthetic
@Deprecated("for binary compatibility", level = DeprecationLevel.HIDDEN)
operator fun plus(another: CharSequence): MessageChain = this.followedBy(another.toString().toMessage())
} }
@MiraiExperimentalAPI
@JvmSynthetic @JvmSynthetic
@HidesMembers
inline operator fun Message.plus(another: Message): MessageChain = this.followedBy(another)
@HidesMembers
@JvmSynthetic
inline operator fun Message.plus(another: SingleMessage): MessageChain = this.followedBy(another)
@HidesMembers
@JvmSynthetic
inline operator fun Message.plus(another: String): MessageChain = this.followedBy(another.toMessage())
@HidesMembers
@JvmSynthetic
inline operator fun Message.plus(another: CharSequence): MessageChain = this.followedBy(another.toString().toMessage())
@HidesMembers
@JvmSynthetic
inline operator fun Message.plus(another: Iterable<Message>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
@JvmName("plus1")
@HidesMembers
@JvmSynthetic
inline operator fun Message.plus(another: Iterable<String>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
@JvmSynthetic
@HidesMembers
inline operator fun Message.plus(another: Sequence<Message>): MessageChain =
another.fold(this, Message::plus).asMessageChain()
@HidesMembers
@JvmSynthetic
inline operator fun Message.plus(another: MessageChain): MessageChain = this + another as Message
@ExperimentalCoroutinesApi @ExperimentalCoroutinesApi
@HidesMembers
@JvmSynthetic
suspend inline operator fun Message.plus(another: Flow<Message>): MessageChain = suspend inline operator fun Message.plus(another: Flow<Message>): MessageChain =
another.fold(this) { acc, it -> acc + it }.asMessageChain() another.fold(this) { acc, it -> acc + it }.asMessageChain()
...@@ -271,9 +227,6 @@ inline val Message.content: String ...@@ -271,9 +227,6 @@ inline val Message.content: String
* - [MessageChain] 所有元素都满足 [isContentEmpty] * - [MessageChain] 所有元素都满足 [isContentEmpty]
*/ */
fun Message.isContentEmpty(): Boolean { fun Message.isContentEmpty(): Boolean {
contract {
returns(false) implies (this@isContentEmpty is MessageContent)
}
return when (this) { return when (this) {
is MessageMetadata -> true is MessageMetadata -> true
is PlainText -> this.content.isEmpty() is PlainText -> this.content.isEmpty()
...@@ -282,12 +235,7 @@ fun Message.isContentEmpty(): Boolean { ...@@ -282,12 +235,7 @@ fun Message.isContentEmpty(): Boolean {
} }
} }
inline fun Message.isContentNotEmpty(): Boolean { inline fun Message.isContentNotEmpty(): Boolean = !this.isContentEmpty()
contract {
returns(true) implies (this@isContentNotEmpty is MessageContent)
}
return !this.isContentEmpty()
}
inline fun Message.isPlain(): Boolean { inline fun Message.isPlain(): Boolean {
contract { contract {
...@@ -364,7 +312,6 @@ interface MessageMetadata : SingleMessage { ...@@ -364,7 +312,6 @@ interface MessageMetadata : SingleMessage {
/** /**
* 返回空字符串 * 返回空字符串
*/ */
@Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION")
final override fun contentToString(): String = "" final override fun contentToString(): String = ""
} }
......
...@@ -26,12 +26,12 @@ internal class SubscribingGetTest { ...@@ -26,12 +26,12 @@ internal class SubscribingGetTest {
runBlockingWithTimeout(10000) { runBlockingWithTimeout(10000) {
suspendCancellableCoroutine<Unit> { cont -> suspendCancellableCoroutine<Unit> { cont ->
launch { launch {
syncFromEvent(3000) { _: TestEvent -> syncFromEvent(8000) { _: TestEvent ->
cont.resume(Unit) cont.resume(Unit)
} }
} }
launch { launch {
delay(2000) delay(4000)
TestEvent().broadcast() TestEvent().broadcast()
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment