[JS FIR] Implement FirJsReflectionAPICallChecker diagnostic
^KT-60899 Fixed
This commit is contained in:
committed by
Space Team
parent
af7eb8b7af
commit
d5aaa29a7f
+5
-9
@@ -18,20 +18,16 @@ package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.ReflectionTypes
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.AbstractReflectionApiCallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
private val ADDITIONAL_ALLOWED_CLASSES = setOf(
|
||||
FqName("kotlin.reflect.AssociatedObjectKey"),
|
||||
FqName("kotlin.reflect.ExperimentalAssociatedObjects")
|
||||
)
|
||||
|
||||
class JsReflectionAPICallChecker(
|
||||
reflectionTypes: ReflectionTypes,
|
||||
storageManager: StorageManager
|
||||
@@ -45,8 +41,8 @@ class JsReflectionAPICallChecker(
|
||||
context: CallCheckerContext
|
||||
): Boolean {
|
||||
return super.isAllowedReflectionApi(descriptor, containingClass, context) ||
|
||||
containingClass.fqNameSafe in ADDITIONAL_ALLOWED_CLASSES ||
|
||||
descriptor.name.asString() == "findAssociatedObject"
|
||||
containingClass.classId in StandardClassIds.associatedObjectAnnotations ||
|
||||
descriptor.name == StandardNames.FqNames.findAssociatedObject.shortName()
|
||||
}
|
||||
|
||||
override fun report(element: PsiElement, context: CallCheckerContext) {
|
||||
|
||||
Reference in New Issue
Block a user