From 77e38dd964d6978bd8a2977ff129625d5f3e841c Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 30 Oct 2020 09:48:32 +0800 Subject: [PATCH] Check instanceReceiver before call --- .../mamoe/mirai/console/internal/command/CommandReflector.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt index 116d5c068..d6e3a85e0 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/command/CommandReflector.kt @@ -254,6 +254,10 @@ internal class CommandReflector( val instanceParameter = function.instanceParameter if (instanceParameter != null) { + check(instanceParameter.type.classifierAsKClass().isInstance(command)) { + "Bad command call resolved. " + + "Function expects instance parameter ${instanceParameter.type} whereas actual instance is ${command::class}." + } args[instanceParameter] = command }