Just like how
when requires all subtypes of a sealed class to be handled, it would be nice if I could define an interface that requires a method to handle each subtype of the sealed class. My use case is a Kafka topic where multiple message types are put onto one topic. I currently have message handler function that accepts the parent sealed class as the parameter type and a
when block to pass each subtype of the sealed class to a handler method. It would be nicer if I could just define a method for each subclass, though.
Is there any way to do that? Or would it have to be a new feature built into the language?