From 2dd82b31df05627cf6e9d6488f44d05faaf258df Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 17 May 2020 01:07:32 +0800 Subject: [PATCH] Rename reified parsers --- .../console/command/description/CommandParserContext.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandParserContext.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandParserContext.kt index ad4f0096d..e771ee284 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandParserContext.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/description/CommandParserContext.kt @@ -17,6 +17,7 @@ import net.mamoe.mirai.console.command.description.CommandParserContext.ParserPa import net.mamoe.mirai.contact.Friend import net.mamoe.mirai.contact.Group import net.mamoe.mirai.contact.Member +import net.mamoe.mirai.utils.MiraiExperimentalAPI import kotlin.internal.LowPriorityInOverloadResolution import kotlin.reflect.KClass import kotlin.reflect.full.isSubclassOf @@ -126,7 +127,7 @@ class CommandParserContextBuilder : MutableList> by mutableListOf( inline infix fun KClass.with(parser: CommandArgParser): ParserPair<*> = ParserPair(this, parser).also { add(it) } - inline infix fun add(parser: CommandArgParser): ParserPair<*> = + inline infix fun auto(parser: CommandArgParser): ParserPair<*> = ParserPair(T::class, parser).also { add(it) } /** @@ -149,17 +150,19 @@ class CommandParserContextBuilder : MutableList> by mutableListOf( /** * 添加一个指令解析器 */ + @MiraiExperimentalAPI @JvmSynthetic - inline infix fun add( + inline infix fun auto( crossinline parser: CommandArgParser<*>.(s: String) -> T ): ParserPair<*> = T::class with CommandArgParser { s: String, _: CommandSender -> parser(s) } /** * 添加一个指令解析器 */ + @MiraiExperimentalAPI @JvmSynthetic @LowPriorityInOverloadResolution - inline infix fun add( + inline infix fun auto( crossinline parser: CommandArgParser<*>.(s: String, sender: CommandSender) -> T ): ParserPair<*> = T::class with CommandArgParser(parser) }