diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt index 97d39c1a4e..50c68c1090 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourWithFSMStateHandlerHolder.kt @@ -34,10 +34,9 @@ class BehaviourWithFSMStateHandlerHolder( handleState(state as I) } - override suspend fun StatesMachine.handleState(state: O): O? = if (this is BehaviourContextWithFSM) { - handleState(state) - } else { - null + override suspend fun StatesMachine.handleState(state: O): O? = with(delegateTo) { + @Suppress("UNCHECKED_CAST") + handleState(state as I) } }