From dc0ba1d8ffdd27335cdc72ebbcdc51346b4e3c65 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Mon, 21 Sep 2020 12:47:53 +0800 Subject: [PATCH] Fix SemVersionRangeRequirementBuilder --- .../console/util/SemVersionRangeRequirementBuilder.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersionRangeRequirementBuilder.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersionRangeRequirementBuilder.kt index 74145d1f8..be4b936ce 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersionRangeRequirementBuilder.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/util/SemVersionRangeRequirementBuilder.kt @@ -26,7 +26,7 @@ public object SemVersionRangeRequirementBuilder { } override fun toString(): String { - return "(${this@or}) or ($other)" + return "{${this@or}} || {$other}" } } } @@ -48,7 +48,7 @@ public object SemVersionRangeRequirementBuilder { } override fun toString(): String { - return "(${this@and}) or ($other)" + return "{${this@and}} && {$other}" } } } @@ -64,7 +64,12 @@ public object SemVersionRangeRequirementBuilder { @Suppress("NOTHING_TO_INLINE") @ILoveHim188moeForever - public inline fun custom(rule: SemVersion.Requirement): SemVersion.Requirement = rule + public fun custom(rule: (SemVersion) -> Boolean): SemVersion.Requirement = object : SemVersion.Requirement { + override fun test(version: SemVersion): Boolean = rule(version) + override fun toString(): String { + return "Custom{$rule}" + } + } /** * 标注一个 [SemVersionRangeRequirementBuilder] DSL