<Generic Enum of certain type> I would like to enf...
# forum
r
Generic Enum of certain type I would like to enforce, at compile time, the type of a parameter to an Enum that also implements an interface: interface MyInterface { val value: String } enum class WrongTypeEnum { WrongEnum1, WrongEnum2, } enum class CorrectTypeEnum(override val value: String) : MyInterface { CorrectEnum1("value1"), CorrectEnum2("value2"); } If I write a generic function, things work correctly: fun myFunction(param: T) {...} myFunction(CorrectTypeEnum.TestEnum1) // compiles...