title: Enum.valueOf in Kotlin
body: <p>Is there a way to make something like this work in Kotlin without the reflection?</p>
  
  <pre><code>inline fun &lt;reified T : kotlin.Enum&lt;T&gt;&gt; safeValueOf(type: String?): T? {
      return java.lang.Enum.valueOf(T::class.java, type)
  }
  </code></pre>
  
  <p>The example below doesn't compile due to:</p>
  
  <blockquote>
    <p>Type parameter bound for T in <code>inline fun &lt;reified T : kotlin.Enum&lt;T&gt;&gt; safeValueOf(type: kotlin.String?): T?</code>
    is not satisfied: inferred type <code>TestEnum?</code> is not a subtype of <code>kotlin.Enum&lt;TestEnum?&gt;</code></p>
  </blockquote>
  
  <pre><code>enum class TestEnum
  
  fun main() {
      val value: TestEnum? = safeValueOf("test")
  }
  </code></pre>