KJS: don't export declarations marked as external or annotated by native or library annotations
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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";
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: main.kt
|
||||
|
||||
package foo
|
||||
|
||||
external class A {
|
||||
class B
|
||||
}
|
||||
|
||||
inline fun getA() = A::class
|
||||
inline fun getB() = foo<A.B>()
|
||||
|
||||
inline fun <reified T> 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() {}
|
||||
Reference in New Issue
Block a user