Kotlin Sealed Interfaces: Make Missing Request States a Compile Error
Kotlin sealed interfaces replace ambiguous nullable flags with explicit request states. Here is a worked example, a compile-time verification plan, and the trade-offs to consider.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Kotlin sealed interfaces replace ambiguous nullable flags with explicit request states. Here is a worked example, a compile-time verification plan, and the trade-offs to consider.
Kotlin sealed classes and interfaces model finite domain states with compiler-checked exhaustive when expressions. Covers syntax, serialization, sealed interfaces for multiple inheritance, and production trade-offs: binary compatibility, DEX count, R8 stripping.
Nullable data/error field pairs silently break when a new state is added. Kotlin sealed interfaces make the set of states closed, so the compiler flags every when that misses a case.