Reference to Enum.valueOf()

Hi,

I’d like to ask how to get reference to SomeEnum.valueOf(), so i can use it as parameter of type xf: (String) -> T. I can use it indirectly via lambda etc., but it is compiled to extra pieces of code.

I don’t think it is possible because the valueOf() function is not a member function but rather a companion object function of the enum class.

You can see an example of this in the stdlib: CharCategory.valueOf()

You can reference companion object functions as Class.Companion::function, but this does not work here. If you add companion to enum with helper function doing conversion, it is referencable, but
it results in other extra code.

Add this as an extension function:

inline fun <reified T> enumValueOfFunction() = { value: String ->  enumValueOf<T>(value)}