ephemient
06/30/2026, 4:32 AMentries up to date nor write out the values overrides when they're basically all the same shape.ephemient
06/30/2026, 4:36 AMentries, we ended up using
val entries: List<Switch<*>> = Switch::class.sealedSubclasses.map { it.objectInstance as Switch<*> }
(well actually we're nesting the classes and using
val entries: List<Switch<*>> = Switch::class.java.declaredClasses.mapNotNull {
if (Switch::class.java.isAssignableFrom(it)) {
it.getDeclaredField("INSTANCE").apply { isAccessible = true }.get(null) as Switch<*>
} else null
}
to avoid kotlin.reflect at runtime, but it's basically the same idea)ephemient
06/30/2026, 4:39 AMephemient
06/30/2026, 4:40 AMvalues overrides, but ran into issuesephemient
06/30/2026, 4:42 AMTernary.values resolves to Switch::values.invoke(Ternary)ephemient
06/30/2026, 4:44 AMoverload val in the subclasses, I still see IrProperty("values") and IrFunction("<get-values>") when processing the subclasses. however, even if I add bodies to them or replace them entirely in an IrElementTransformerVoid, my changes don't seem to show up in the compiled classes. is there something magically eliding them?Pavel Kunyavskiy [JB]
06/30/2026, 6:38 AMPavel Kunyavskiy [JB]
06/30/2026, 6:39 AMPavel Kunyavskiy [JB]
06/30/2026, 6:41 AMinline <reified T> val Switch<T>.values = enumEntries<T>()
But then you wouldn't be able to call on unknown type, so maybe it's not that useful.Youssef Shoaib [MOD]
06/30/2026, 6:44 AM