Feature Request: Type-Directed Omission (Enum Dot Syntax)

There was some discussion of this a few months back.

There was discussion of conflicting enums, import [...] as, typealias, and readability.

IMHO this kind of change has some potential cons and has possible alternative solutions (if the issue of readability of the enum is impactful enough). I’d also throw in minus 100 points.

It might be worth considering proposing this feature in a heavily limited form, like only available in a when clause–which was at some point planned for Kotlin (see Refer to enums by short name?)

And you can always import the enum with a wild card:

import somepackage.Color.*

fun main() {
   val c: Color = BLUE
   val message = when (c) {
      BLUE -> "It's blue"
      RED -> "It's red"
   }
   println(message)
}
1 Like