diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt index 6352c917d21..7b34c5b72c3 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt @@ -22,10 +22,10 @@ fun Int.set6(a: Double, v: String): Number fun Any.foo(a: String = "0.0", v: String = "str") = "OK" @nativeSetter -fun Int.set(a: A): Int? = 1 +fun Int.set(a: A): Int? = 1 @nativeSetter fun Int.set2(): String? = "OK" @nativeSetter -fun Int.set3(a: Any, b: Int, c: Any?) {} \ No newline at end of file +fun Int.set3(a: Any, b: Int, c: Any?) {} diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt index aad1c154253..ab6704ca204 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt @@ -27,8 +27,8 @@ import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker +import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf @@ -68,12 +68,12 @@ internal abstract class AbstractNativeIndexerChecker( override fun additionalCheck(declaration: KtNamedFunction, descriptor: FunctionDescriptor, diagnosticHolder: DiagnosticSink) { val parameters = descriptor.valueParameters val builtIns = descriptor.builtIns - if (parameters.size > 0) { - val firstParamClassDescriptor = DescriptorUtils.getClassDescriptorForType(parameters.get(0).type) - if (firstParamClassDescriptor != builtIns.string && - !DescriptorUtils.isSubclass(firstParamClassDescriptor, builtIns.number) - ) { - diagnosticHolder.report(ErrorsJs.NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER.on(declaration.valueParameters.first(), indexerKind)) + if (parameters.isNotEmpty()) { + val firstParamType = parameters.first().type + if (!KotlinBuiltIns.isString(firstParamType) && !firstParamType.isSubtypeOf(builtIns.number.defaultType)) { + diagnosticHolder.report( + ErrorsJs.NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER.on(declaration.valueParameters.first(), indexerKind) + ) } }