Support KClass.isInstance/cast/safeCast in stdlib-only reflection implementation
#KT-14720 Fixed
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ abstract class AbstractReflectionApiCallChecker(
|
||||
private val kClass by storageManager.createLazyValue { reflectionTypes.kClass }
|
||||
|
||||
protected open fun isAllowedKClassMember(name: Name): Boolean =
|
||||
name.asString() == "simpleName"
|
||||
name.asString() == "simpleName" || name.asString() == "isInstance"
|
||||
|
||||
final override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
if (isWholeReflectionApiAvailable) return
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.cast
|
||||
import kotlin.reflect.full.safeCast
|
||||
import kotlin.reflect.cast
|
||||
import kotlin.reflect.safeCast
|
||||
import kotlin.test.*
|
||||
|
||||
fun testInstance(value: Any?, klass: KClass<*>) {
|
||||
|
||||
@@ -39,6 +39,7 @@ fun <T : Any> kclass(k: KClass<*>, kt: KClass<T>) {
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>isCompanion<!>
|
||||
|
||||
k.<!NO_REFLECTION_IN_CLASS_PATH!>annotations<!>
|
||||
k.isInstance(42)
|
||||
|
||||
k == kt
|
||||
k.hashCode()
|
||||
|
||||
Reference in New Issue
Block a user