I'd like to check if reified generic T is implemen...
# compiler
j
I'd like to check if reified generic T is implementing an interface.
Copy code
interface Destination {}
interface Dialog : Destination {}

inline fun <reified T : Destination> add() {
   val isDialog1 = T is Dialog // does not compile
   val isDialog2 = Dialog::class.java.isAssignableFrom(T::class.java) // works, but uses Java reflection
   val isDialog3 = (typeOf<T>().classifier as KClass<T>).isSubclassOf(Dialog::class) // works, but uses Kotlin full reflection, doesn't it?
}
Isn't there any compiler optimized way to do this? But THB, I'm not including kotlin full reflection to my dependencies, so maybe the third way IS optimized?