run.smt.ktest.util.reflection.reflection.kt Maven / Gradle / Ivy
package run.smt.ktest.util.reflection
import kotlin.reflect.KClass
inline fun Class<*>.canBeAssignedTo() = this canBeAssignedTo R::class
infix fun Class<*>.canBeAssignedTo(other: KClass<*>) = other.java.isAssignableFrom(this) || other.javaObjectType.isAssignableFrom(this)
inline fun KClass<*>.canBeAssignedTo() = this canBeAssignedTo R::class
infix fun KClass<*>.canBeAssignedTo(other: Class): Boolean {
return other.isAssignableFrom(this.java)
|| other.isAssignableFrom(this.javaObjectType)
}
infix fun KClass<*>.canBeAssignedTo(other: KClass<*>): Boolean {
return other.java.isAssignableFrom(this.java)
|| other.java.isAssignableFrom(this.javaObjectType)
|| other.javaObjectType.isAssignableFrom(this.java)
|| other.javaObjectType.isAssignableFrom(this.javaObjectType)
}