Fix command receiverParameter, #215

This commit is contained in:
Him188 2020-10-30 09:48:12 +08:00
parent bace377d1e
commit 3b14d70cc5

View File

@ -256,6 +256,15 @@ internal class CommandReflector(
if (instanceParameter != null) { if (instanceParameter != null) {
args[instanceParameter] = command args[instanceParameter] = command
} }
val receiverParameter = function.extensionReceiverParameter
if (receiverParameter != null) {
check(receiverParameter.type.classifierAsKClass().isInstance(call.caller)) {
"Bad command call resolved. " +
"Function expects receiver parameter ${receiverParameter.type} whereas actual is ${call.caller::class}."
}
args[receiverParameter] = call.caller
}
function.callSuspendBy(args) function.callSuspendBy(args)
} }
}.toList() }.toList()