From 52ccf3d6ec3f9858bd82bb4da4ed4dada8d13c76 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Thu, 23 Dec 2021 15:21:00 +0000 Subject: [PATCH] [JS IR] Not export fun with stable name and default argument if it is not exported, but just with stable name ^KT-50464 fixed Merge-request: KT-MR-5324 Merged-by: Ilya Goncharov --- .../ir/backend/js/lower/ExportedDefaultParameterStub.kt | 6 ++++-- .../typescript-export/selectiveExport/selectiveExport.kt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt index 6b806fc98c5..76172115acf 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt @@ -15,11 +15,11 @@ import org.jetbrains.kotlin.backend.common.lower.irBlockBody import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin +import org.jetbrains.kotlin.ir.backend.js.export.isExported import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder import org.jetbrains.kotlin.ir.backend.js.utils.JsAnnotations import org.jetbrains.kotlin.ir.backend.js.utils.hasStableJsName import org.jetbrains.kotlin.ir.builders.* -import org.jetbrains.kotlin.ir.builders.declarations.addFunction import org.jetbrains.kotlin.ir.builders.declarations.buildFun import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -105,7 +105,9 @@ class ExportedDefaultParameterStub(val context: JsIrBackendContext) : Declaratio origin = JsIrBuilder.SYNTHESIZED_DECLARATION } - context.additionalExportedDeclarations.add(exportedDefaultStubFun) + if (declaration.isExported(context)) { + context.additionalExportedDeclarations.add(exportedDefaultStubFun) + } exportedDefaultStubFun.parent = declaration.parent exportedDefaultStubFun.copyParameterDeclarationsFrom(declaration) diff --git a/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.kt b/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.kt index 8d6050d2834..61f9fb7f518 100644 --- a/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.kt +++ b/js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.kt @@ -30,6 +30,9 @@ class Class external interface ExternalInterface +@JsName("bbb") +fun zzz(x: Int = 10) {} + // FILE: file2.kt @file:JsExport