mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Fix StringConstant.toString and add notes for AbstractCommandValueParameter implementers
This commit is contained in:
parent
fd2a22a798
commit
21428094a8
@ -208,6 +208,8 @@ public sealed class AbstractCommandValueParameter<T> : CommandValueParameter<T>,
|
||||
public override val isVararg: Boolean,
|
||||
public override val type: KType,
|
||||
) : AbstractCommandValueParameter<T>() {
|
||||
override fun toString(): String = super.toString()
|
||||
|
||||
init {
|
||||
requireNotNull(type.classifierAsKClassOrNull()) {
|
||||
"type.classifier must be KClass."
|
||||
@ -237,7 +239,5 @@ public sealed class AbstractCommandValueParameter<T> : CommandValueParameter<T>,
|
||||
* Extended by [CommandValueArgumentParser]
|
||||
*/
|
||||
@ConsoleExperimentalApi
|
||||
public abstract class Extended<T> : AbstractCommandValueParameter<T>() {
|
||||
abstract override fun toString(): String
|
||||
}
|
||||
public abstract class Extended<T> : AbstractCommandValueParameter<T>() // For implementer: take care of toString()
|
||||
}
|
@ -58,9 +58,9 @@ public abstract class AbstractCommandSignature : CommandSignature {
|
||||
override fun toString(): String {
|
||||
val receiverParameter = receiverParameter
|
||||
return if (receiverParameter == null) {
|
||||
"CommandSignatureVariant(${valueParameters.joinToString()})"
|
||||
"CommandSignature(${valueParameters.joinToString()})"
|
||||
} else {
|
||||
"CommandSignatureVariant($receiverParameter, ${valueParameters.joinToString()})"
|
||||
"CommandSignature($receiverParameter, ${valueParameters.joinToString()})"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +181,8 @@ internal class TestCommand {
|
||||
@Test
|
||||
fun `composite command descriptors`() {
|
||||
val overloads = TestCompositeCommand.overloads
|
||||
assertEquals("CommandSignatureVariant(<mute>, seconds: Int = ...)", overloads[0].toString())
|
||||
assertEquals("CommandSignatureVariant(<mute>, target: Long, seconds: Int)", overloads[1].toString())
|
||||
assertEquals("CommandSignature(<mute>, seconds: Int = ...)", overloads[0].toString())
|
||||
assertEquals("CommandSignature(<mute>, target: Long, seconds: Int)", overloads[1].toString())
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user