Skip to content

Commit

Permalink
Leverage sealed hierarchy for cast that will always succeed (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Aug 22, 2024
1 parent 4714b9c commit bbc5455
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class HostProtocolAdapter<W : Any>(
factory: ProtocolFactory<W>,
private val eventSink: EventSink,
) : ChangesSink {
private val factory = requireNotNull(factory as? GeneratedProtocolFactory<W>) {
"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<Id, ProtocolNode<W>>(
Expand Down

0 comments on commit bbc5455

Please sign in to comment.