From bbc545573e43d5cf843c572dfdae528176c09152 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 22 Aug 2024 17:17:02 -0400 Subject: [PATCH] Leverage sealed hierarchy for cast that will always succeed (#2257) --- .../app/cash/redwood/protocol/host/HostProtocolAdapter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/HostProtocolAdapter.kt b/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/HostProtocolAdapter.kt index e7a01e1434..50db1fc4b0 100644 --- a/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/HostProtocolAdapter.kt +++ b/redwood-protocol-host/src/commonMain/kotlin/app/cash/redwood/protocol/host/HostProtocolAdapter.kt @@ -52,8 +52,8 @@ public class HostProtocolAdapter( factory: ProtocolFactory, private val eventSink: EventSink, ) : ChangesSink { - private val factory = requireNotNull(factory as? GeneratedProtocolFactory) { - "Factory ${factory::class} was not generated by Redwood or is out of date" + private val factory = when (factory) { + is GeneratedProtocolFactory -> factory } private val nodes = mutableMapOf>(