KJS: allow to use KClass::isInstance; implement isInstance in KClassImpl

This commit is contained in:
Zalim Bashorov
2016-10-15 17:36:06 +03:00
parent 6caf3c1c0f
commit a085df914f
7 changed files with 37 additions and 4 deletions
@@ -28,6 +28,8 @@ import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.storage.getValue
private val ALLOWED_KCLASS_MEMBERS = setOf("simpleName", "isInstance")
class JsReflectionAPICallChecker(private val module: ModuleDescriptor, storageManager: StorageManager) : AbstractReflectionApiCallChecker(module, storageManager) {
override val isWholeReflectionApiAvailable: Boolean
get() = false
@@ -40,5 +42,5 @@ class JsReflectionAPICallChecker(private val module: ModuleDescriptor, storageMa
override fun isAllowedReflectionApi(descriptor: CallableDescriptor, containingClass: ClassDescriptor): Boolean =
super.isAllowedReflectionApi(descriptor, containingClass) ||
DescriptorUtils.isSubclass(containingClass, kClass) && descriptor.name.asString() == "simpleName"
DescriptorUtils.isSubclass(containingClass, kClass) && descriptor.name.asString() in ALLOWED_KCLASS_MEMBERS
}