Remove generic type on MessageVisitorUnit

This commit is contained in:
Him188 2022-04-26 12:39:36 +01:00
parent 287769799a
commit d6a56f1052
4 changed files with 6 additions and 12 deletions

View File

@ -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

View File

@ -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
}
/**

View File

@ -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)

View File

@ -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)