Enum.valueOf in Kotlin

Your function works if you specify the type parameter value explicitly:

val value = safeValueOf<TestEnum>("test")

The original code is supposed to work as well, but doesn’t work because of a bug in the type inference implementation: https://youtrack.jetbrains.com/issue/KT-11218

Leave a Comment