mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-16 15:52:18 +00:00
[JS IR BE] Use fresh name for external JsModule declarations.
This commit is contained in:
@@ -370,7 +370,7 @@ class NameTables(
|
||||
declaration !is IrDeclarationWithName ->
|
||||
return
|
||||
|
||||
declaration.isEffectivelyExternal() ->
|
||||
declaration.isEffectivelyExternal() && (declaration.getJsModule() == null || declaration.isJsNonModule()) ->
|
||||
globalNames.declareStableName(declaration, declaration.getJsNameOrKotlinName().identifier)
|
||||
|
||||
else ->
|
||||
|
||||
@@ -4948,6 +4948,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/jsModule/externalFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunctionNameClash.kt")
|
||||
public void testExternalFunctionNameClash() throws Exception {
|
||||
runTest("js/js.translator/testData/box/jsModule/externalFunctionNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunctionPlain.kt")
|
||||
public void testExternalFunctionPlain() throws Exception {
|
||||
runTest("js/js.translator/testData/box/jsModule/externalFunctionPlain.kt");
|
||||
|
||||
@@ -4963,6 +4963,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/jsModule/externalFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunctionNameClash.kt")
|
||||
public void testExternalFunctionNameClash() throws Exception {
|
||||
runTest("js/js.translator/testData/box/jsModule/externalFunctionNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunctionPlain.kt")
|
||||
public void testExternalFunctionPlain() throws Exception {
|
||||
runTest("js/js.translator/testData/box/jsModule/externalFunctionPlain.kt");
|
||||
|
||||
5
js/js.translator/testData/box/jsModule/externalFunctionNameClash.js
vendored
Normal file
5
js/js.translator/testData/box/jsModule/externalFunctionNameClash.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
define("lib", [], function() {
|
||||
return function(y) {
|
||||
return 23 + y;
|
||||
};
|
||||
});
|
||||
14
js/js.translator/testData/box/jsModule/externalFunctionNameClash.kt
vendored
Normal file
14
js/js.translator/testData/box/jsModule/externalFunctionNameClash.kt
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1284
|
||||
// MODULE_KIND: AMD
|
||||
package foo
|
||||
|
||||
@JsModule("lib")
|
||||
external fun foo(y: Int): Int = definedExternally
|
||||
|
||||
fun foo(y: String): String = y + "K"
|
||||
|
||||
fun box(): String {
|
||||
val foo10 = foo(10)
|
||||
if (foo10 != 33) return "Fail: $foo10"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user