I see, but the idea is to not be limited by inline...
# language-proposals
d
I see, but the idea is to not be limited by inline functions. For example, now we can’t use reified type parameters in interfaces. If we need a
Class<T>
inside, we have to pass it to the function as a parameter. But if the compiler did this for us, code would look better:
Copy code
// we write
interface Interface {
  fun <reified T> foo(bar: Any): T?
}
class Class : Interface {
  override fun <reified T> foo(bar: Any) : T? {
    if (bar is T) {
      return bar
    }

    return null
  }
}

// Kotlin compiler translates to
interface Interface {
  fun <T> foo(tclass: Class<T>, bar: Any): T?
}
class Class : Interface {
  override fun <T> foo(tclass: Class<T>, bar: Any): T? {
    if (tclass.isInstance(bar)) {
      @Suppress("UNCHECKED_CAST")
      return bar as T
    }

    return null
  }
}