This repository was archived by the owner on Jan 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Support Enum Companion #41
Copy link
Copy link
Open
Labels
wontfixThis will not be worked onThis will not be worked on
Description
@KustomExport
enum class E {
EnumValue;
companion object {
val static = 1
}
}generates
@JsExport
public class E internal constructor(
internal val common: CommonE,
) {
public val name: String = common.name
}
@JsExport
public fun E_values(): Array<E> = arrayOf(E_EnumValue, E_Companion)
@JsExport
public fun E_valueOf(name: String): E? {
if (name == E_EnumValue.name)
return E_EnumValue
if (name == E_Companion.name)
return E_Companion
return null
}
public fun E.importE(): CommonE = common
public fun CommonE.exportE(): E = E_valueOf(this.name)!!
@JsExport
public val E_EnumValue: E = E(CommonE.EnumValue)
@JsExport
public val E_Companion: E = E(CommonE.Companion)which is an error because Type mismatch: inferred type is E.Companion but E was expected in the last line. The incorrect assumption is made that the companion object is an enum value.
Workaround: Use JsExport instead of KustomExport
glureau
Metadata
Metadata
Assignees
Labels
wontfixThis will not be worked onThis will not be worked on