diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.kt b/compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.kt new file mode 100644 index 00000000000..6647b77c8ef --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.kt @@ -0,0 +1,29 @@ +// FIR_IDENTICAL +// !OPT_IN: kotlin.js.ExperimentalJsExport +// !RENDER_DIAGNOSTICS_MESSAGES + +@file:JsExport + +package foo + +@JsExport.Ignore +inline fun inlineReifiedFun(x: Any) = x is T + +@JsExport.Ignore +suspend fun suspendFun() { } + +@JsExport.Ignore +val String.extensionProperty get() = this.length + +@JsExport.Ignore +val Array<*>.extensionProperty get() = this.size + +@JsExport.Ignore +annotation class AnnotationClass + +class AnotherClass { + @JsExport.Ignore + val String.extensionProperty get() = this.length + @JsExport.Ignore + val Array<*>.extensionProperty get() = this.size +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.txt b/compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.txt new file mode 100644 index 00000000000..3bde91834af --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.txt @@ -0,0 +1,24 @@ +package + +package foo { + @kotlin.js.JsExport.Ignore public val kotlin.Array<*>.extensionProperty: kotlin.Int + @kotlin.js.JsExport.Ignore public val kotlin.String.extensionProperty: kotlin.Int + @kotlin.js.JsExport.Ignore public inline fun inlineReifiedFun(/*0*/ x: kotlin.Any): kotlin.Boolean + @kotlin.js.JsExport.Ignore public suspend fun suspendFun(): kotlin.Unit + + @kotlin.js.JsExport.Ignore public final annotation class AnnotationClass : kotlin.Annotation { + public constructor AnnotationClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class AnotherClass { + public constructor AnotherClass() + @kotlin.js.JsExport.Ignore public final val kotlin.Array<*>.extensionProperty: kotlin.Int + @kotlin.js.JsExport.Ignore public final val kotlin.String.extensionProperty: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJsStdLibGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJsStdLibGenerated.java index 2c9349510f2..a9e5f72b9df 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJsStdLibGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticsTestWithJsStdLibGenerated.java @@ -514,6 +514,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes public void testWrongExportedDeclarationInExportedFile() throws Exception { runTest("compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFile.kt"); } + + @Test + @TestMetadata("wrongExportedDeclarationInExportedFileWhenIgnored.kt") + public void testWrongExportedDeclarationInExportedFileWhenIgnored() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.kt"); + } } @Nested diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java b/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java index 8f2c7360b68..344fc36f45a 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java @@ -128,6 +128,12 @@ public final class AnnotationsUtils { } if (hasAnnotationOrInsideAnnotatedClass(descriptor, JS_EXPORT_IGNORE)) return false; + + if (descriptor instanceof PropertyAccessorDescriptor) { + PropertyAccessorDescriptor propertyAccessor = (PropertyAccessorDescriptor) descriptor; + if (propertyAccessor.getCorrespondingProperty().getAnnotations().hasAnnotation(JS_EXPORT_IGNORE)) return false; + } + if (hasAnnotationOrInsideAnnotatedClass(descriptor, JS_EXPORT)) return true; if (CollectionsKt.any(getContainingFileAnnotations(bindingContext, descriptor), annotation -> diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java index 051712daefa..b2a0ec5b49f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsOldFrontendDiagnosticsTestGenerated.java @@ -515,6 +515,12 @@ public class FirPsiJsOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiJ public void testWrongExportedDeclarationInExportedFile() throws Exception { runTest("compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFile.kt"); } + + @Test + @TestMetadata("wrongExportedDeclarationInExportedFileWhenIgnored.kt") + public void testWrongExportedDeclarationInExportedFileWhenIgnored() throws Exception { + runTest("compiler/testData/diagnostics/testsWithJsStdLib/export/wrongExportedDeclarationInExportedFileWhenIgnored.kt"); + } } @Nested