Union types

I made this propose translating the enum class to union class, enumerations are a single type with multiple values, all with same tye, union types are types with a single value of multiple types.

So the example

union class FlexibleDate { String, Number, LocalDate }

can become

sealed class FlexibleDate {
    inline class String(private val value: String) : FlexibleDate() { operator fun getValue() = value }
    inline class Number(private val value: Number) : FlexibleDate() { operator fun getValue() = value }
    inline class LocalDate(private val value: LocalDate) : FlexibleDate() { operator fun getValue() = value }
}


fun parse(text: String): FlexibleDate = TODO()

fun print(date: FlexibleDate) {
    when(date){
        is FlexibleDate.String -> println("String" + date.getValue())
        is FlexibleDate.Number -> println("Number" + date.getValue())
        is FlexibleDate.LocalDate -> println("LocalDate" + date.getValue())
    }
}

For gerValue see KEEP/flexible-delegated-property-convention.md at a8f082023fda207a73296e68d61916d2c94293aa · Kotlin/KEEP · GitHub