Hey folks :wave: I just released sealed-class-enum...
# feed
w
Hey folks 👋 I just released sealed-class-enumizer, a Kotlin (K2) compiler plugin that generates enum-like operations —
entries
,
valueOf
,
label
and friends — for
sealed class
/
sealed interface
hierarchies at compile time. Sealed hierarchies are the usual answer to "an enum whose cases carry data", but you lose the operational API: no
entries
, no
valueOf
, no way to put "which case" in a signature without fabricating an instance. The common workaround is a hand-maintained parallel enum that silently goes stale — this plugin generates that layer instead:
Copy code
@Enumize
sealed interface Status {
    data class Active(val remarks: String) : Status
    data object Deleted : Status
}

Status.Enumish.entries             // every case, no instances needed
Status.Enumish.valueOf("Active")   // label-based lookup (+ valueOfOrNull)
Status.Active                      // each case gets a "kind" singleton usable in signatures & exhaustive `when`, like an enum value
• No runtime reflection — works on Kotlin/JVM, JS, Wasm and Native, where
KClass.sealedSubclasses
can't go (JVM-only, silently broken by R8) • Leaves keep their expressive power: data-carrying, smart casts, exhaustive
when
— they can even stay
open
• Modules consuming your library don't need the plugin — the generated API is regular metadata • Gradle & Maven, published on the Gradle Plugin Portal / Maven Central (Kotlin 2.4.x, K2 only) github.com/ProjectMapK/sealed-class-enumizer This is 0.1.0 — feedback and issues are very welcome! 🙏
kodee happy 3