Discriminated unions allow you to encode a closed set of variants (which is what you're doing with the sealed class in Kotlin).
sealed class