diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt index 8184c4c1151..02daa4b5d79 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -1019,6 +1019,47 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirJsErrors.NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN) { firDiagnostic -> + NativeAnnotationsAllowedOnlyOnMemberOrExtensionFunImpl( + firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a), + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirJsErrors.NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER) { firDiagnostic -> + NativeIndexerKeyShouldBeStringOrNumberImpl( + firDiagnostic.a, + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirJsErrors.NATIVE_INDEXER_WRONG_PARAMETER_COUNT) { firDiagnostic -> + NativeIndexerWrongParameterCountImpl( + firDiagnostic.a, + firDiagnostic.b, + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirJsErrors.NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS) { firDiagnostic -> + NativeIndexerCanNotHaveDefaultArgumentsImpl( + firDiagnostic.a, + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirJsErrors.NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE) { firDiagnostic -> + NativeGetterReturnTypeShouldBeNullableImpl( + firDiagnostic as KtPsiDiagnostic, + token, + ) + } + add(FirJsErrors.NATIVE_SETTER_WRONG_RETURN_TYPE) { firDiagnostic -> + NativeSetterWrongReturnTypeImpl( + firDiagnostic as KtPsiDiagnostic, + token, + ) + } add(FirErrors.OPT_IN_USAGE) { firDiagnostic -> OptInUsageImpl( firDiagnostic.a, diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt index 503752ac83f..630dc8aca14 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnostics.kt @@ -732,6 +732,35 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = RuntimeAnnotationOnExternalDeclaration::class } + abstract class NativeAnnotationsAllowedOnlyOnMemberOrExtensionFun : KtFirDiagnostic() { + override val diagnosticClass get() = NativeAnnotationsAllowedOnlyOnMemberOrExtensionFun::class + abstract val type: KtType + } + + abstract class NativeIndexerKeyShouldBeStringOrNumber : KtFirDiagnostic() { + override val diagnosticClass get() = NativeIndexerKeyShouldBeStringOrNumber::class + abstract val kind: String + } + + abstract class NativeIndexerWrongParameterCount : KtFirDiagnostic() { + override val diagnosticClass get() = NativeIndexerWrongParameterCount::class + abstract val parametersCount: Int + abstract val kind: String + } + + abstract class NativeIndexerCanNotHaveDefaultArguments : KtFirDiagnostic() { + override val diagnosticClass get() = NativeIndexerCanNotHaveDefaultArguments::class + abstract val kind: String + } + + abstract class NativeGetterReturnTypeShouldBeNullable : KtFirDiagnostic() { + override val diagnosticClass get() = NativeGetterReturnTypeShouldBeNullable::class + } + + abstract class NativeSetterWrongReturnType : KtFirDiagnostic() { + override val diagnosticClass get() = NativeSetterWrongReturnType::class + } + abstract class OptInUsage : KtFirDiagnostic() { override val diagnosticClass get() = OptInUsage::class abstract val optInMarkerFqName: FqName diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 0718c270647..52d24b6176d 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -880,6 +880,41 @@ internal class RuntimeAnnotationOnExternalDeclarationImpl( override val token: KtLifetimeToken, ) : KtFirDiagnostic.RuntimeAnnotationOnExternalDeclaration(), KtAbstractFirDiagnostic +internal class NativeAnnotationsAllowedOnlyOnMemberOrExtensionFunImpl( + override val type: KtType, + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.NativeAnnotationsAllowedOnlyOnMemberOrExtensionFun(), KtAbstractFirDiagnostic + +internal class NativeIndexerKeyShouldBeStringOrNumberImpl( + override val kind: String, + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.NativeIndexerKeyShouldBeStringOrNumber(), KtAbstractFirDiagnostic + +internal class NativeIndexerWrongParameterCountImpl( + override val parametersCount: Int, + override val kind: String, + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.NativeIndexerWrongParameterCount(), KtAbstractFirDiagnostic + +internal class NativeIndexerCanNotHaveDefaultArgumentsImpl( + override val kind: String, + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.NativeIndexerCanNotHaveDefaultArguments(), KtAbstractFirDiagnostic + +internal class NativeGetterReturnTypeShouldBeNullableImpl( + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.NativeGetterReturnTypeShouldBeNullable(), KtAbstractFirDiagnostic + +internal class NativeSetterWrongReturnTypeImpl( + override val firDiagnostic: KtPsiDiagnostic, + override val token: KtLifetimeToken, +) : KtFirDiagnostic.NativeSetterWrongReturnType(), KtAbstractFirDiagnostic + internal class OptInUsageImpl( override val optInMarkerFqName: FqName, override val message: String, diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt index d75eed04e96..0713e236d41 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirJsDiagnosticsList.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticL import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.PositioningStrategy import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.psi.* @Suppress("UNUSED_VARIABLE", "LocalVariableName", "ClassName", "unused") @@ -23,6 +24,21 @@ object JS_DIAGNOSTICS_LIST : DiagnosticList("FirJsErrors") { val NESTED_JS_MODULE_PROHIBITED by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) val RUNTIME_ANNOTATION_NOT_SUPPORTED by warning(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) val RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) + val NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { + parameter("type") + } + val NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { + parameter("kind") + } + val NATIVE_INDEXER_WRONG_PARAMETER_COUNT by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { + parameter("parametersCount") + parameter("kind") + } + val NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { + parameter("kind") + } + val NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE by error(PositioningStrategy.DECLARATION_RETURN_TYPE) + val NATIVE_SETTER_WRONG_RETURN_TYPE by error(PositioningStrategy.DECLARATION_RETURN_TYPE) } val SUPERTYPES by object : DiagnosticGroup("Supertypes") { diff --git a/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt b/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt index 8b9a08d5fc9..fa5612f360c 100644 --- a/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt +++ b/compiler/fir/checkers/checkers.js/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrors.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory import org.jetbrains.kotlin.fir.analysis.diagnostics.* import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.psi.KtAnonymousInitializer import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration @@ -32,6 +33,12 @@ object FirJsErrors { val NESTED_JS_MODULE_PROHIBITED by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) val RUNTIME_ANNOTATION_NOT_SUPPORTED by warning0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) val RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) + val NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) + val NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) + val NATIVE_INDEXER_WRONG_PARAMETER_COUNT by error2(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) + val NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) + val NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE by error0(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE) + val NATIVE_SETTER_WRONG_RETURN_TYPE by error0(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE) // Supertypes val WRONG_MULTIPLE_INHERITANCE by error1>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt index 3700b310ae8..0cd6d12c996 100644 --- a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/diagnostics/js/FirJsErrorsDefaultMessages.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics.js import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap +import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers @@ -26,6 +27,12 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.INLINE_EXTER import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_MODULE_PROHIBITED_ON_NON_NATIVE import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.JS_MODULE_PROHIBITED_ON_VAR import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_JS_MODULE_PROHIBITED +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_INDEXER_WRONG_PARAMETER_COUNT +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NATIVE_SETTER_WRONG_RETURN_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_CLASS_IN_EXTERNAL_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NESTED_EXTERNAL_DECLARATION import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors.NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE @@ -101,6 +108,27 @@ object FirJsErrorsDefaultMessages : BaseDiagnosticRendererFactory() { NON_ABSTRACT_MEMBER_OF_EXTERNAL_INTERFACE, "Only nullable properties of external interfaces are allowed to be non-abstract" ) + map.put( + NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN, + "Annotation ''{0}'' is allowed only on member functions of declaration annotated as ''kotlin.js.native'' or on toplevel extension functions", + FirDiagnosticRenderers.RENDER_TYPE + ) + map.put( + NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER, + "Native {0}''s first parameter type should be ''kotlin.String'' or subtype of ''kotlin.Number''", + CommonRenderers.STRING + ) + map.put(NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS, "Native {0}''s parameter can not have default value", CommonRenderers.STRING) + map.put(NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE, "Native getter's return type should be nullable") + map.put( + NATIVE_SETTER_WRONG_RETURN_TYPE, + "Native setter's return type should be 'Unit' or a supertype of the second parameter's type" + ) + map.put( + NATIVE_INDEXER_WRONG_PARAMETER_COUNT, "Expected {0} parameters for native {1}", + KtDiagnosticRenderers.TO_STRING, + CommonRenderers.STRING + ) map.checkMissingMessages(FirJsErrors) } diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/JsDeclarationCheckers.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/JsDeclarationCheckers.kt index 2ea9ea665bb..bde8c352d44 100644 --- a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/JsDeclarationCheckers.kt +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/JsDeclarationCheckers.kt @@ -33,4 +33,11 @@ object JsDeclarationCheckers : DeclarationCheckers() { FirJsDynamicDeclarationChecker, FirJsInheritanceClassChecker, ) + + override val simpleFunctionCheckers: Set + get() = setOf( + FirJsNativeInvokeChecker, + FirJsNativeGetterChecker, + FirJsNativeSetterChecker, + ) } diff --git a/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/declaration/FirJsNativeAnnotationCheckers.kt b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/declaration/FirJsNativeAnnotationCheckers.kt new file mode 100644 index 00000000000..61ecfe50f73 --- /dev/null +++ b/compiler/fir/checkers/checkers.js/src/org/jetbrains/kotlin/fir/analysis/js/checkers/declaration/FirJsNativeAnnotationCheckers.kt @@ -0,0 +1,132 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.js.checkers.declaration + +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.diagnostics.reportOn +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirSimpleFunctionChecker +import org.jetbrains.kotlin.fir.analysis.js.checkers.isNativeObject +import org.jetbrains.kotlin.fir.analysis.checkers.isTopLevel +import org.jetbrains.kotlin.fir.analysis.diagnostics.js.FirJsErrors +import org.jetbrains.kotlin.fir.declarations.FirFunction +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.hasAnnotation +import org.jetbrains.kotlin.fir.declarations.utils.isExtension +import org.jetbrains.kotlin.fir.declarations.utils.visibility +import org.jetbrains.kotlin.fir.expressions.classId +import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.JsStandardClassIds + +internal abstract class FirJsAbstractNativeAnnotationChecker(private val requiredAnnotation: ClassId) : FirSimpleFunctionChecker() { + protected fun FirFunction.hasRequiredAnnotation(context: CheckerContext) = hasAnnotation(requiredAnnotation, context.session) + + override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) { + val annotation = declaration.annotations.find { it.classId == requiredAnnotation } ?: return + + val isMember = !context.isTopLevel && declaration.visibility != Visibilities.Local + val isExtension = declaration.isExtension + + if (isMember && (isExtension || !declaration.symbol.isNativeObject(context)) || !isMember && !isExtension) { + reporter.reportOn( + declaration.source, + FirJsErrors.NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN, + annotation.typeRef.coneType, + context + ) + } + } +} + +internal object FirJsNativeInvokeChecker : FirJsAbstractNativeAnnotationChecker(JsStandardClassIds.Annotations.JsNativeInvoke) + +internal abstract class FirJsAbstractNativeIndexerChecker( + requiredAnnotation: ClassId, + private val indexerKind: String, + private val requiredParametersCount: Int, +) : FirJsAbstractNativeAnnotationChecker(requiredAnnotation) { + override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) { + super.check(declaration, context, reporter) + + val parameters = declaration.valueParameters + val builtIns = context.session.builtinTypes + + if (parameters.isNotEmpty()) { + val firstParameterDeclaration = parameters.first() + val firstParameter = firstParameterDeclaration.returnTypeRef.coneType + + if ( + firstParameter !is ConeErrorType && + !firstParameter.isString && + !firstParameter.isSubtypeOf(builtIns.numberType.coneType, context.session) + ) { + reporter.reportOn( + firstParameterDeclaration.source, + FirJsErrors.NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER, + indexerKind, + context + ) + } + } + + if (parameters.size != requiredParametersCount) { + reporter.reportOn( + declaration.source, + FirJsErrors.NATIVE_INDEXER_WRONG_PARAMETER_COUNT, + requiredParametersCount, + indexerKind, + context + ) + } + + for (parameter in parameters) { + if (parameter.defaultValue != null) { + reporter.reportOn( + parameter.source, + FirJsErrors.NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS, + indexerKind, + context + ) + } + } + } +} + +internal object FirJsNativeGetterChecker : FirJsAbstractNativeIndexerChecker(JsStandardClassIds.Annotations.JsNativeGetter, "getter", 1) { + override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) { + if (!declaration.hasRequiredAnnotation(context)) return + super.check(declaration, context, reporter) + + if (!declaration.returnTypeRef.coneType.isNullable) { + reporter.reportOn(declaration.source, FirJsErrors.NATIVE_GETTER_RETURN_TYPE_SHOULD_BE_NULLABLE, context) + } + } +} + +internal object FirJsNativeSetterChecker : FirJsAbstractNativeIndexerChecker(JsStandardClassIds.Annotations.JsNativeSetter, "setter", 2) { + override fun check(declaration: FirSimpleFunction, context: CheckerContext, reporter: DiagnosticReporter) { + if (!declaration.hasRequiredAnnotation(context)) return + super.check(declaration, context, reporter) + + val returnType = declaration.returnTypeRef.coneType + if (returnType.isUnit) { + return + } + + if (declaration.valueParameters.size < 2) { + return + } + + val secondParameterType = declaration.valueParameters[1].returnTypeRef.coneType + if (secondParameterType.isSubtypeOf(returnType, context.session)) { + return + } + + reporter.reportOn(declaration.source, FirJsErrors.NATIVE_SETTER_WRONG_RETURN_TYPE, context) + } +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSession.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSession.kt index d0ef4c8bf5e..b0b64a14d1c 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSession.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirSession.kt @@ -59,6 +59,7 @@ class BuiltinTypes { val enumType: FirImplicitBuiltinTypeRef = FirImplicitEnumTypeRef(null) val annotationType: FirImplicitBuiltinTypeRef = FirImplicitAnnotationTypeRef(null) val booleanType: FirImplicitBuiltinTypeRef = FirImplicitBooleanTypeRef(null) + val numberType: FirImplicitBuiltinTypeRef = FirImplicitNumberTypeRef(null) val byteType: FirImplicitBuiltinTypeRef = FirImplicitByteTypeRef(null) val shortType: FirImplicitBuiltinTypeRef = FirImplicitShortTypeRef(null) val intType: FirImplicitBuiltinTypeRef = FirImplicitIntTypeRef(null) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt index ef5c2c3b3bc..60428e7c5dc 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt @@ -76,6 +76,10 @@ class FirImplicitBooleanTypeRef( source: KtSourceElement? ) : FirImplicitBuiltinTypeRef(source, StandardClassIds.Boolean) +class FirImplicitNumberTypeRef( + source: KtSourceElement? +) : FirImplicitBuiltinTypeRef(source, StandardClassIds.Number) + class FirImplicitByteTypeRef( source: KtSourceElement? ) : FirImplicitBuiltinTypeRef(source, StandardClassIds.Byte) @@ -194,6 +198,7 @@ fun FirImplicitBuiltinTypeRef.withNewSource(newSource: KtSourceElement?): FirImp is FirImplicitAnnotationTypeRef -> FirImplicitAnnotationTypeRef(newSource) is FirImplicitBooleanTypeRef -> FirImplicitBooleanTypeRef(newSource) is FirImplicitByteTypeRef -> FirImplicitByteTypeRef(newSource) + is FirImplicitNumberTypeRef -> FirImplicitNumberTypeRef(newSource) is FirImplicitShortTypeRef -> FirImplicitShortTypeRef(newSource) is FirImplicitIntTypeRef -> FirImplicitIntTypeRef(newSource) is FirImplicitLongTypeRef -> FirImplicitLongTypeRef(newSource) diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.fir.kt deleted file mode 100644 index 006b9f7a843..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -fun foo() { - @nativeGetter - fun Int.get(a: String): Int? = 1 - - @nativeGetter - fun Int.get2(a: Number): String? = "OK" - - @nativeGetter - fun Int.get3(a: Int): String? = "OK" - - @nativeGetter - fun Int.get(a: Any): Int? = 1 - - @nativeGetter - fun Int.get2(): String? = "OK" - - @nativeGetter - fun Int.get3(a: Any, b: Int, c: Any?): String? = "OK" - - @nativeGetter - fun Any.foo(a: Int = 1): Any? = "OK" -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.kt index c609adc164d..6234dc05ec6 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalExtensionFun.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION fun foo() { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.fir.kt deleted file mode 100644 index 5c4c4da8769..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -fun foo() { - class A { - @nativeGetter - fun get(a: String): Any? = null - - @nativeGetter - fun take(a: Number): String? = null - - @nativeGetter - fun foo(a: Double): String? = null - } - - class B { - @nativeGetter - val foo = 0 - } - - class C { - @nativeGetter - fun Int.get(a: String): Int? = 1 - - @nativeGetter - fun Int.get2(a: Number): String? = "OK" - - @nativeGetter - fun Int.get3(a: Int): String? = "OK" - - @nativeGetter - fun get(): Any? = null - - @nativeGetter - fun get(a: A): Any? = null - - @nativeGetter - fun foo(a: Int) {} - - @nativeGetter - fun bar(a: String): Int = 0 - - @nativeGetter - fun baz(a: Int = 0): Int? = 0 - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.kt index d3e2e51384a..42547cc2817 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalNonNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION fun foo() { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.fir.kt deleted file mode 100644 index 7cac9c47d7d..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -fun foo() { - @nativeGetter - fun toplevelFun(): Any = 0 - - @nativeGetter - val toplevelVal = 0 - - @nativeGetter - class Foo {} -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.kt index ec809efa050..9bfb52116d7 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onLocalOtherDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION fun foo() { @@ -9,4 +10,4 @@ fun foo() { @nativeGetter class Foo {} -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.fir.kt deleted file mode 100644 index 8dff53b9f0e..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.fir.kt +++ /dev/null @@ -1,57 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -external class A { - @nativeGetter - fun get(a: String): Any? = definedExternally - - @nativeGetter - fun take(a: Number): String? = definedExternally - - @nativeGetter - fun foo(a: Double): String? = definedExternally - - companion object { - @nativeGetter - fun get(a: String): Any? = definedExternally - - @nativeGetter - fun take(a: Number): String? = definedExternally - - @nativeGetter - fun foo(a: Double): String? = definedExternally - } -} - -external class B { - @nativeGetter - val foo: Int = definedExternally - - @nativeGetter - object Obj1 {} - - companion object { - @nativeGetter - val foo: Int = definedExternally - - @nativeGetter - object Obj2 {} - } -} - -external class C { - @nativeGetter - fun get(): Any? = definedExternally - - @nativeGetter - fun get(a: A): Any? = definedExternally - - @nativeGetter - fun foo(a: Int) { definedExternally } - - @nativeGetter - fun bar(a: String): Int = definedExternally - - @nativeGetter - fun baz(a: String = definedExternally): Int? = definedExternally - -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.kt index e35b6696d29..3afa0c6bd20 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION external class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.fir.kt deleted file mode 100644 index c73fbf6ac3e..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.fir.kt +++ /dev/null @@ -1,77 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -external class A { - class B { - class A { - @nativeGetter - fun get(a: String): Any? = definedExternally - - @nativeGetter - fun take(a: Number): String? = definedExternally - - @nativeGetter - fun foo(a: Double): String? = definedExternally - - companion object { - @nativeGetter - fun get(a: String): Any? = definedExternally - - @nativeGetter - fun take(a: Number): String? = definedExternally - - @nativeGetter - fun foo(a: Double): String? = definedExternally - } - } - - class B { - @nativeGetter - val foo: Int = definedExternally - - @nativeGetter - object Obj1 {} - - companion object { - @nativeGetter - val foo: Int = definedExternally - - @nativeGetter - object Obj2 {} - } - } - - class C { - @nativeGetter - fun get(): Any? = definedExternally - - @nativeGetter - fun get(a: A): Any? = definedExternally - - @nativeGetter - fun foo(a: Int) { definedExternally } - - @nativeGetter - fun bar(a: String): Int = definedExternally - - @nativeGetter - fun baz(a: Number = definedExternally): Int? = definedExternally - } - - object obj { - @nativeGetter - fun get(): Any? = definedExternally - - @nativeGetter - fun get(a: A): Any? = definedExternally - - @nativeGetter - fun foo(a: Int) { definedExternally } - - @nativeGetter - fun bar(a: String): Int = definedExternally - - @nativeGetter - fun baz(a: String = definedExternally): Int? = definedExternally - } - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.kt index cc28b1aac6d..c976cd50b37 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNativeClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION external class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.fir.kt deleted file mode 100644 index cdbc04b02a0..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.fir.kt +++ /dev/null @@ -1,112 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -class A { - class B { - class A { - @nativeGetter - fun get(a: String): Any? = null - - @nativeGetter - fun take(a: Number): String? = null - - @nativeGetter - fun foo(a: Double): String? = null - - companion object { - @nativeGetter - fun get(a: String): Any? = null - - @nativeGetter - fun take(a: Number): String? = null - - @nativeGetter - fun foo(a: Double): String? = null - } - } - - class B { - @nativeGetter - fun Int.get(a: String): Int? = 1 - - @nativeGetter - fun Int.get2(a: Number): String? = "OK" - - @nativeGetter - fun Int.get3(a: Int): String? = "OK" - - @nativeGetter - val foo = 0 - - @nativeGetter - object Obj1 {} - - companion object { - @nativeGetter - val foo = 0 - - @nativeGetter - object Obj2 {} - - @nativeGetter - fun Int.get(a: String): Int? = 1 - - @nativeGetter - fun Int.get2(a: Number): String? = "OK" - - @nativeGetter - fun Int.get3(a: Int): String? = "OK" - } - } - - class C { - @nativeGetter - fun get(): Any? = null - - @nativeGetter - fun get(a: A): Any? = null - - @nativeGetter - fun foo(a: Int) {} - - @nativeGetter - fun bar(a: String): Int = 0 - - @nativeGetter - fun baz(a: String = "foo"): Int? = 0 - } - - object obj { - @nativeGetter - fun get(): Any? = null - - @nativeGetter - fun get(a: A): Any? = null - - @nativeGetter - fun foo(a: Int) {} - - @nativeGetter - fun bar(a: String): Int = 0 - - @nativeGetter - fun baz(a: Double = 0.0): Int? = 0 - } - - val anonymous = object { - @nativeGetter - fun get(): Any? = null - - @nativeGetter - fun get(a: A): Any? = null - - @nativeGetter - fun foo(a: Int) {} - - @nativeGetter - fun bar(a: String): Int = 0 - - @nativeGetter - fun baz(a: String = "foo"): Int? = 0 - } - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.kt index 3026f8b5523..dd1e27caefb 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNestedDeclarationsInsideNonNativeClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.fir.kt deleted file mode 100644 index 23d6d845445..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.fir.kt +++ /dev/null @@ -1,65 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -class A { - @nativeGetter - fun get(a: String): Any? = null - - @nativeGetter - fun take(a: Number): String? = null - - @nativeGetter - fun foo(a: Double): String? = null - - companion object { - @nativeGetter - fun get(a: String): Any? = null - - @nativeGetter - fun take(a: Number): String? = null - - @nativeGetter - fun foo(a: Double): String? = null - } -} - -class B { - @nativeGetter - val foo = 0 - - @nativeGetter - object Obj1 {} - - companion object { - @nativeGetter - val foo = 0 - - @nativeGetter - object Obj2 {} - } -} - -class C { - @nativeGetter - fun Int.get(a: String): Int? = 1 - - @nativeGetter - fun Int.get2(a: Number): String? = "OK" - - @nativeGetter - fun Int.get3(a: Int): String? = "OK" - - @nativeGetter - fun get(): Any? = null - - @nativeGetter - fun get(a: A): Any? = null - - @nativeGetter - fun foo(a: Int) {} - - @nativeGetter - fun bar(a: String): Int = 0 - - @nativeGetter - fun baz(a: String = "foo"): Int? = 0 -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.kt index 37acb6cfc4e..675f87f6a0c 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onNonNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.fir.kt deleted file mode 100644 index 2a71d183832..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.fir.kt +++ /dev/null @@ -1,22 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -@nativeGetter -fun Int.get(a: String): Int? = 1 - -@nativeGetter -fun Int.get2(a: Number): String? = "OK" - -@nativeGetter -fun Int.get3(a: Int): String? = "OK" - -@nativeGetter -fun Int.baz(a: Int = 0): String? = "OK" - -@nativeGetter -fun Int.get(a: Any): Int? = 1 - -@nativeGetter -fun Int.get2(): String? = "OK" - -@nativeGetter -fun Int.get3(a: Any, b: Int, c: Any?): String? = "OK" diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.kt index 784c4223c0a..bdc04a0c8b4 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelExtensionFun.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION @nativeGetter diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.fir.kt deleted file mode 100644 index 40bbd7615b9..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -@nativeGetter -fun toplevelFun(): Any = 0 - -@nativeGetter -val toplevelVal = 0 - -@nativeGetter -class Foo {} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.kt index 7fdb032583e..f78bc58136e 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeGetter/onToplevelOtherDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION @nativeGetter diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.fir.kt deleted file mode 100644 index 3957421f690..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -fun foo() { - class A { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - - @nativeInvoke - fun Int.ext() = 1 - - @nativeInvoke - fun Int.invoke(a: String, b: Int) = "OK" - - val anonymous = object { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - } - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.kt index a86ad81d2d1..c0e72c37429 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalNonNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION fun foo() { @@ -22,4 +23,4 @@ fun foo() { fun invoke(a: String): Int = 0 } } -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.fir.kt deleted file mode 100644 index 9dc7b983aea..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -fun foo() { - @nativeInvoke - fun toplevelFun() {} - - @nativeInvoke - val toplevelVal = 0 - - @nativeInvoke - class Foo {} -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.kt index f2ed82f2040..ba05d69ace7 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onLocalOtherDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION fun foo() { @@ -9,4 +10,4 @@ fun foo() { @nativeInvoke class Foo {} -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.fir.kt deleted file mode 100644 index aa8bc287f18..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.fir.kt +++ /dev/null @@ -1,43 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -class A { - class B { - class C { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - - @nativeInvoke - fun Int.ext() = 1 - - @nativeInvoke - fun Int.invoke(a: String, b: Int) = "OK" - } - - object obj { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - } - - companion object { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - } - - val anonymous = object { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - } - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.kt index 5fd829c4801..9b63bd80e46 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNestedDeclarationsInsideNonNativeClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION class A { @@ -40,4 +41,4 @@ class A { fun invoke(a: String): Int = 0 } } -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.fir.kt deleted file mode 100644 index 73dbce1bc3e..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.fir.kt +++ /dev/null @@ -1,35 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -class A { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - - @nativeInvoke - fun Int.ext() = 1 - - @nativeInvoke - fun Int.invoke(a: String, b: Int) = "OK" - - @nativeInvoke - val baz = 0 - - @nativeInvoke - object Obj {} - - companion object { - @nativeInvoke - fun foo() {} - - @nativeInvoke - fun invoke(a: String): Int = 0 - - @nativeInvoke - fun Int.ext() = 1 - - @nativeInvoke - fun Int.invoke(a: String, b: Int) = "OK" - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.kt index ce1f6a5f0d3..9c41c6deca5 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onNonNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.fir.kt deleted file mode 100644 index ad6bfcee373..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -@nativeInvoke -fun toplevelFun() {} - -@nativeInvoke -val toplevelVal = 0 - -@nativeInvoke -class Foo {} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.kt index 0a5e542a226..dfcccae8b7e 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeInvoke/onToplevelOtherDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION @nativeInvoke diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.fir.kt deleted file mode 100644 index d889b573d86..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.fir.kt +++ /dev/null @@ -1,33 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -fun foo() { - @nativeSetter - fun Int.set(a: String, v: Int) {} - - @nativeSetter - fun Int.set2(a: Number, v: String?): Any? = null - - @nativeSetter - fun Int.set3(a: Double, v: String) = "OK" - - @nativeSetter - fun Int.set4(a: Double, v: String): Any = 1 - - @nativeSetter - fun Int.set5(a: Double, v: String): CharSequence = "OK" - - @nativeSetter - fun Int.set6(a: Double, v: String): Number = 1 - - @nativeSetter - fun Int.set(a: Any): Int? = 1 - - @nativeSetter - fun Int.set2(): String? = "OK" - - @nativeSetter - fun Int.set3(a: Any, b: Int, c: Any?) {} - - @nativeSetter - fun Any.foo(a: Double = 0.0, v: String? = null) = "OK" -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.kt index 56da7aa9eaa..d2c6493cdec 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalExtensionFun.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION fun foo() { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.fir.kt deleted file mode 100644 index 103643893ae..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -fun foo() { - class A { - @nativeSetter - fun set(a: String, v: Any?): Any? = null - - @nativeSetter - fun put(a: Number, v: String) {} - - @nativeSetter - fun foo(a: Int, v: String) {} - } - - class B { - @nativeSetter - var foo = 0 - } - - class C { - @nativeSetter - fun Int.set(a: String, v: Int) {} - - @nativeSetter - fun Int.set2(a: Number, v: String?) = "OK" - - @nativeSetter - fun Int.set3(a: Double, v: String?) = "OK" - - @nativeSetter - fun set(): Any? = null - - @nativeSetter - fun set(a: A): Any? = null - - @nativeSetter - fun set(a: String, v: Any, v2: Any) {} - - @nativeSetter - fun set(a: A, v: Any?) {} - - @nativeSetter - fun foo(a: Int = 0, v: String) = "OK" - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.kt index a3e5f9650e6..9d7e7668b2c 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalNonNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION fun foo() { @@ -42,4 +43,4 @@ fun foo() { @nativeSetter fun foo(a: Int = 0, v: String) = "OK" } -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.fir.kt deleted file mode 100644 index 43371701dfe..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -fun foo() { - @nativeSetter - fun toplevelFun(): Any = 0 - - @nativeSetter - val toplevelVal = 0 - - @nativeSetter - class Foo {} -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.kt index fa222315388..128900620e8 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onLocalOtherDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION fun foo() { @@ -9,4 +10,4 @@ fun foo() { @nativeSetter class Foo {} -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.fir.kt deleted file mode 100644 index 17c27658ceb..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.fir.kt +++ /dev/null @@ -1,71 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -external class A { - @nativeSetter - fun set(a: String, v: Any?): Any? = definedExternally - - @nativeSetter - fun put(a: Number, v: String) { definedExternally } - - @nativeSetter - fun foo(a: Int, v: String) { definedExternally } - - @nativeSetter - fun set4(a: Double, v: String): Any = definedExternally - - @nativeSetter - fun set5(a: Double, v: String): CharSequence = definedExternally - - companion object { - @nativeSetter - fun set(a: String, v: Any?): Any? = definedExternally - - @nativeSetter - fun put(a: Number, v: String) { definedExternally } - - @nativeSetter - fun foo(a: Int, v: String) { definedExternally } - - @nativeSetter - fun set4(a: Double, v: String): Any = definedExternally - - @nativeSetter - fun set5(a: Double, v: String): CharSequence = definedExternally - } -} - -external class B { - @nativeSetter - val foo: Int = definedExternally - - @nativeSetter - object Obj1 {} - - companion object { - @nativeSetter - val foo: Int = definedExternally - - @nativeSetter - object Obj2 {} - } -} - -external class C { - @nativeSetter - fun set6(a: Double, v: String): Number = definedExternally - - @nativeSetter - fun set(): Any? = definedExternally - - @nativeSetter - fun set(a: A): Any? = definedExternally - - @nativeSetter - fun set(a: String, v: Any, v2: Any) { definedExternally } - - @nativeSetter - fun set(a: A, v: Any?) { definedExternally } - - @nativeSetter - fun foo(a: Number, v: String = definedExternally): String = definedExternally -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.kt index a3785127932..cb89b762fca 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION external class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.fir.kt deleted file mode 100644 index 46eac5d32fb..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.fir.kt +++ /dev/null @@ -1,92 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -external class A { - class B { - class A { - @nativeSetter - fun set(a: String, v: Any?): Any? = definedExternally - - @nativeSetter - fun put(a: Number, v: String) { definedExternally } - - @nativeSetter - fun foo(a: Int, v: String) { definedExternally } - - @nativeSetter - fun set4(a: Double, v: String): Any = definedExternally - - @nativeSetter - fun set5(a: Double, v: String): CharSequence = definedExternally - - companion object { - @nativeSetter - fun set(a: String, v: Any?): Any? = definedExternally - - @nativeSetter - fun put(a: Number, v: String) { definedExternally } - - @nativeSetter - fun foo(a: Int, v: String) { definedExternally } - - @nativeSetter - fun set4(a: Double, v: String): Any = definedExternally - - @nativeSetter - fun set5(a: Double, v: String): CharSequence = definedExternally - } - } - - class B { - @nativeSetter - val foo: Int = definedExternally - - @nativeSetter - object Obj1 {} - - companion object { - @nativeSetter - val foo: Int = definedExternally - - @nativeSetter - object Obj2 {} - } - } - - class C { - @nativeSetter - fun set6(a: Double, v: String): Number = definedExternally - - @nativeSetter - fun set(): Any? = definedExternally - - @nativeSetter - fun set(a: A): Any? = definedExternally - - @nativeSetter - fun set(a: String, v: Any, v2: Any) { definedExternally } - - @nativeSetter - fun set(a: A, v: Any?) { definedExternally } - - @nativeSetter - fun foo(a: Double = definedExternally, v: String = definedExternally): String = definedExternally - } - - object obj { - @nativeSetter - fun set(): Any? = definedExternally - - @nativeSetter - fun set(a: A): Any? = definedExternally - - @nativeSetter - fun set(a: String, v: Any, v2: Any) { definedExternally } - - @nativeSetter - fun set(a: A, v: Any?) { definedExternally } - - @nativeSetter - fun foo(a: Int, v: String = definedExternally): String = definedExternally - } - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.kt index 3aad33c5ccf..14d4349ed52 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNativeClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION external class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.fir.kt deleted file mode 100644 index aeb26f2e389..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.fir.kt +++ /dev/null @@ -1,130 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION - -class A { - class B { - class A { - @nativeSetter - fun set(a: String, v: Any?): Any? = null - - @nativeSetter - fun put(a: Number, v: String) {} - - @nativeSetter - fun foo(a: Int, v: String) {} - - @nativeSetter - fun set4(a: Double, v: String): Any = 1 - - @nativeSetter - fun set5(a: Double, v: String): CharSequence = "OK" - - companion object { - @nativeSetter - fun set(a: String, v: Any?): Any? = null - - @nativeSetter - fun put(a: Number, v: String) {} - - @nativeSetter - fun foo(a: Int, v: String) {} - } - } - - class B { - @nativeSetter - val foo = 0 - - @nativeSetter - object Obj1 {} - - companion object { - @nativeSetter - val foo = 0 - - @nativeSetter - object Obj2 {} - } - } - - class C { - @nativeSetter - fun Int.set(a: String, v: Int) {} - - @nativeSetter - fun Int.set2(a: Number, v: String?) = "OK" - - @nativeSetter - fun Int.set3(a: Double, v: String?) = "OK" - - @nativeSetter - fun Int.set6(a: Double, v: String): Number = 1 - - @nativeSetter - fun set(): Any? = null - - @nativeSetter - fun set(a: A): Any? = null - - @nativeSetter - fun set(a: String, v: Any, v2: Any) {} - - @nativeSetter - fun set(a: A, v: Any?) {} - - @nativeSetter - fun foo(a: Double = 0.0, v: String = "str") = "OK" - } - - object obj { - @nativeSetter - fun Int.set(a: String, v: Int) {} - - @nativeSetter - fun Int.set2(a: Number, v: String?) = "OK" - - @nativeSetter - fun Int.set3(a: Double, v: String?) = "OK" - - @nativeSetter - fun set(): Any? = null - - @nativeSetter - fun set(a: A): Any? = null - - @nativeSetter - fun set(a: String, v: Any, v2: Any) {} - - @nativeSetter - fun set(a: A, v: Any?) {} - - @nativeSetter - fun foo(a: Int, v: String = "str") = "OK" - } - - val anonymous = object { - @nativeSetter - fun Int.set(a: String, v: Int) {} - - @nativeSetter - fun Int.set2(a: Number, v: String?) = "OK" - - @nativeSetter - fun Int.set3(a: Double, v: String?) = "OK" - - @nativeSetter - fun set(): Any? = null - - @nativeSetter - fun set(a: A): Any? = null - - @nativeSetter - fun set(a: String, v: Any, v2: Any) {} - - @nativeSetter - fun set(a: A, v: Any?) {} - - @nativeSetter - fun foo(a: Number = 0.0, v: String) = "OK" - } - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.kt index 6571ea29d3e..f4e5e852465 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNestedDeclarationsInsideNonNativeClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -NON_TOPLEVEL_CLASS_DECLARATION, -DEPRECATION class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.fir.kt deleted file mode 100644 index 526e3681148..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.fir.kt +++ /dev/null @@ -1,65 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -class A { - @nativeSetter - fun set(a: String, v: Any?): Any? = null - - @nativeSetter - fun put(a: Number, v: String) {} - - @nativeSetter - fun foo(a: Int, v: String) {} - - companion object { - @nativeSetter - fun set(a: String, v: Any?): Any? = null - - @nativeSetter - fun put(a: Number, v: String) {} - - @nativeSetter - fun foo(a: Int, v: String) {} - } -} - -class B { - @nativeSetter - val foo = 0 - - @nativeSetter - object Obj1 {} - - companion object { - @nativeSetter - val foo = 0 - - @nativeSetter - object Obj2 {} - } -} - -class C { - @nativeSetter - fun Int.set(a: String, v: Int) {} - - @nativeSetter - fun Int.set2(a: Number, v: String?) = "OK" - - @nativeSetter - fun Int.set3(a: Double, v: String?) = "OK" - - @nativeSetter - fun set(): Any? = null - - @nativeSetter - fun set(a: A): Any? = null - - @nativeSetter - fun set(a: String, v: Any, v2: Any) {} - - @nativeSetter - fun set(a: A, v: Any?) {} - - @nativeSetter - fun foo(a: String = "0.0", v: String) = "OK" -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.kt index c3db2b9346d..899094154cf 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onNonNativeClassMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION class A { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.fir.kt deleted file mode 100644 index 59f0cae5dac..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.fir.kt +++ /dev/null @@ -1,31 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -@nativeSetter -fun Int.set(a: String, v: Int) {} - -@nativeSetter -fun Int.set2(a: Number, v: String?): Any? = null - -@nativeSetter -fun Int.set3(a: Double, v: String) = "OK" - -@nativeSetter -fun Int.set4(a: Double, v: String): Any = 1 - -@nativeSetter -fun Int.set5(a: Double, v: String): CharSequence = "OK" - -@nativeSetter -fun Int.set6(a: Double, v: String): Number = 1 - -@nativeSetter -fun Any.foo(a: String = "0.0", v: String = "str") = "OK" - -@nativeSetter -fun Int.set(a: A): Int? = 1 - -@nativeSetter -fun Int.set2(): String? = "OK" - -@nativeSetter -fun Int.set3(a: Any, b: Int, c: Any?) {} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt index 7b34c5b72c3..fbea3cddb31 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelExtensionFun.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION @nativeSetter diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.fir.kt deleted file mode 100644 index f05807945ab..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION - -@nativeSetter -fun toplevelFun(): Any = 0 - -@nativeSetter -val toplevelVal = 0 - -@nativeSetter -class Foo {} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.kt b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.kt index 79cb546fa15..1f39e05b578 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/native/nativeSetter/onToplevelOtherDeclarations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER, -DEPRECATION @nativeSetter