diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index 459c554df9a..4946472880f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -5581,6 +5581,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Native extends AbstractBoxJsTest { + @TestMetadata("accessToCompanionObjectFromInlineFun.kt") + public void testAccessToCompanionObjectFromInlineFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/native/accessToCompanionObjectFromInlineFun.kt"); + doTest(fileName); + } + public void testAllFilesPresentInNative() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/native"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true); } @@ -5789,6 +5795,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { doTest(fileName); } + @TestMetadata("useClassFromInlineFun.kt") + public void testUseClassFromInlineFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/native/useClassFromInlineFun.kt"); + doTest(fileName); + } + @TestMetadata("vararg.kt") public void testVararg() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/native/vararg.kt"); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/DeclarationExporter.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/DeclarationExporter.kt index c401225fa04..2fe833ee060 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/DeclarationExporter.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/DeclarationExporter.kt @@ -20,6 +20,8 @@ import com.google.dart.compiler.backend.js.ast.* import com.google.dart.compiler.backend.js.ast.metadata.staticRef import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils +import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isLibraryObject +import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isNativeObject import org.jetbrains.kotlin.js.translate.utils.JsAstUtils import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.assignment import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils @@ -37,6 +39,7 @@ internal class DeclarationExporter(val context: StaticContext) { fun export(descriptor: MemberDescriptor, force: Boolean) { if (exportedDeclarations.contains(descriptor)) return if (descriptor is ConstructorDescriptor && descriptor.isPrimary) return + if (isNativeObject(descriptor) || isLibraryObject(descriptor)) return val suggestedName = context.nameSuggestion.suggest(descriptor) ?: return diff --git a/js/js.translator/testData/box/native/accessToCompanionObjectFromInlineFun.kt b/js/js.translator/testData/box/native/accessToCompanionObjectFromInlineFun.kt new file mode 100644 index 00000000000..81d4ac08c0e --- /dev/null +++ b/js/js.translator/testData/box/native/accessToCompanionObjectFromInlineFun.kt @@ -0,0 +1,21 @@ +// FILE: main.kt + +package foo + +external class B { + companion object { + val value: String + } +} + +inline fun test() = B.value + +fun box(): String { + return test() +} + +// FILE: native.js + +function B() {}; + +B.value = "OK"; diff --git a/js/js.translator/testData/box/native/useClassFromInlineFun.kt b/js/js.translator/testData/box/native/useClassFromInlineFun.kt new file mode 100644 index 00000000000..03cadb70df6 --- /dev/null +++ b/js/js.translator/testData/box/native/useClassFromInlineFun.kt @@ -0,0 +1,24 @@ +// FILE: main.kt + +package foo + +external class A { + class B +} + +inline fun getA() = A::class +inline fun getB() = foo() + +inline fun foo() = T::class + +fun box(): String { + if (getA() != A::class) return "fail1" + if (getB() != A.B::class) return "fail2" + + return "OK" +} + +// FILE: native.js + +function A() {} +A.B = function B() {}