mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Check receiver type in init
This commit is contained in:
parent
3933c3e8fb
commit
3f0d123421
@ -22,6 +22,7 @@ import net.mamoe.mirai.console.util.ConsoleExperimentalApi
|
|||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KFunction
|
import kotlin.reflect.KFunction
|
||||||
import kotlin.reflect.KType
|
import kotlin.reflect.KType
|
||||||
|
import kotlin.reflect.full.isSubclassOf
|
||||||
import kotlin.reflect.full.isSubtypeOf
|
import kotlin.reflect.full.isSubtypeOf
|
||||||
import kotlin.reflect.typeOf
|
import kotlin.reflect.typeOf
|
||||||
|
|
||||||
@ -183,9 +184,13 @@ public class CommandReceiverParameter<T : CommandSender>(
|
|||||||
override val name: String get() = PARAMETER_NAME
|
override val name: String get() = PARAMETER_NAME
|
||||||
|
|
||||||
init {
|
init {
|
||||||
check(type.classifier is KClass<*>) {
|
val classifier = type.classifier
|
||||||
|
require(classifier is KClass<*>) {
|
||||||
"CommandReceiverParameter.type.classifier must be KClass."
|
"CommandReceiverParameter.type.classifier must be KClass."
|
||||||
}
|
}
|
||||||
|
require(classifier.isSubclassOf(CommandSender::class)) {
|
||||||
|
"CommandReceiverParameter.type.classifier must be subclass of CommandSender."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user