mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-22 13:46:13 +08:00
Remove generic type on MessageVisitorUnit
This commit is contained in:
parent
287769799a
commit
d6a56f1052
@ -117,12 +117,6 @@ internal object ConstrainSingleHelper {
|
||||
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
@Suppress("UNCHECKED_CAST", "DEPRECATION_ERROR", "DEPRECATION")
|
||||
internal fun <M : SingleMessage> MessageChain.getImpl(key: MessageKey<M>): M? {
|
||||
return this.asSequence().mapNotNull { key.safeCast.invoke(it) }.firstOrNull()
|
||||
}
|
||||
|
||||
@RequiresOptIn
|
||||
internal annotation class MessageChainConstructor
|
||||
|
||||
|
@ -209,10 +209,10 @@ public abstract class AbstractMessageVisitor<in D, out R> : MessageVisitor<D, R>
|
||||
* @since 2.12
|
||||
*/
|
||||
@MiraiInternalApi
|
||||
public abstract class RecursiveMessageVisitor<D> : MessageVisitorUnit<D>() {
|
||||
public abstract class RecursiveMessageVisitor<D> : MessageVisitorUnit() {
|
||||
protected open fun isFinished(): Boolean = false
|
||||
|
||||
override fun visitMessage(message: Message, data: D) {
|
||||
override fun visitMessage(message: Message, data: Unit) {
|
||||
if (isFinished()) return
|
||||
message.acceptChildren(this, data)
|
||||
}
|
||||
@ -223,8 +223,8 @@ public abstract class RecursiveMessageVisitor<D> : MessageVisitorUnit<D>() {
|
||||
* @since 2.12
|
||||
*/
|
||||
@MiraiInternalApi
|
||||
public abstract class MessageVisitorUnit<in D> : AbstractMessageVisitor<D, Unit>() {
|
||||
override fun visitMessage(message: Message, data: D): Unit = Unit
|
||||
public abstract class MessageVisitorUnit : AbstractMessageVisitor<Unit, Unit>() {
|
||||
override fun visitMessage(message: Message, data: Unit): Unit = Unit
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ internal class CombinedMessageTest {
|
||||
@Test
|
||||
fun acceptChildrenTest() {
|
||||
val list = buildList {
|
||||
complexCombined.acceptChildren(object : MessageVisitorUnit<Unit>() {
|
||||
complexCombined.acceptChildren(object : MessageVisitorUnit() {
|
||||
override fun visitMessage(message: Message, data: Unit) {
|
||||
add(message)
|
||||
super.visitMessage(message, data)
|
||||
|
@ -65,7 +65,7 @@ internal class LinearMessageChainImplTest {
|
||||
@Test
|
||||
fun acceptChildrenTest() {
|
||||
val list = buildList {
|
||||
complexLinearChain.acceptChildren(object : MessageVisitorUnit<Unit>() {
|
||||
complexLinearChain.acceptChildren(object : MessageVisitorUnit() {
|
||||
override fun visitMessage(message: Message, data: Unit) {
|
||||
add(message)
|
||||
super.visitMessage(message, data)
|
||||
|
Loading…
Reference in New Issue
Block a user