[Wasm] Fix external functions import clashing
This commit is contained in:
+4
-1
@@ -54,7 +54,10 @@ class DeclarationGenerator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun jsCodeName(declaration: IrFunction): String {
|
private fun jsCodeName(declaration: IrFunction): String {
|
||||||
return declaration.fqNameWhenAvailable!!.asString() + "_" + (declaration as IrSimpleFunction).wasmSignature(irBuiltIns).hashCode()
|
require(declaration is IrSimpleFunction)
|
||||||
|
val fqName = declaration.fqNameWhenAvailable!!.asString()
|
||||||
|
val hashCode = declaration.wasmSignature(irBuiltIns).hashCode() + declaration.file.path.hashCode()
|
||||||
|
return "${fqName}_$hashCode"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunction(declaration: IrFunction) {
|
override fun visitFunction(declaration: IrFunction) {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// IGNORE_BACKEND: JS_IR, JS
|
||||||
|
// FILE: file1.kt
|
||||||
|
@JsFun("() => 42")
|
||||||
|
private external fun clashName(): Int
|
||||||
|
|
||||||
|
public fun getClashName1(): Int = clashName()
|
||||||
|
|
||||||
|
// FILE: file2.kt
|
||||||
|
@JsFun("() => 24")
|
||||||
|
private external fun clashName(): Int
|
||||||
|
|
||||||
|
public fun getClashName2(): Int = clashName()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
|
||||||
|
if (getClashName1() != 42) return "Error1"
|
||||||
|
if (getClashName2() != 24) return "Error2"
|
||||||
|
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Generated
+6
@@ -73,6 +73,12 @@ public class FirJsCodegenWasmJsInteropTestGenerated extends AbstractFirJsCodegen
|
|||||||
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nameClash.kt")
|
||||||
|
public void testNameClash() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxWasmJsInterop/nameClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("types.kt")
|
@TestMetadata("types.kt")
|
||||||
public void testTypes() throws Exception {
|
public void testTypes() throws Exception {
|
||||||
|
|||||||
Generated
+6
@@ -73,6 +73,12 @@ public class IrCodegenWasmJsInteropJsTestGenerated extends AbstractIrCodegenWasm
|
|||||||
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nameClash.kt")
|
||||||
|
public void testNameClash() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxWasmJsInterop/nameClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("types.kt")
|
@TestMetadata("types.kt")
|
||||||
public void testTypes() throws Exception {
|
public void testTypes() throws Exception {
|
||||||
|
|||||||
+5
@@ -85,6 +85,11 @@ public class IrCodegenWasmJsInteropWasmTestGenerated extends AbstractIrCodegenWa
|
|||||||
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nameClash.kt")
|
||||||
|
public void testNameClash() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/boxWasmJsInterop/nameClash.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nullableExternRefs.kt")
|
@TestMetadata("nullableExternRefs.kt")
|
||||||
public void testNullableExternRefs() throws Exception {
|
public void testNullableExternRefs() throws Exception {
|
||||||
runTest("compiler/testData/codegen/boxWasmJsInterop/nullableExternRefs.kt");
|
runTest("compiler/testData/codegen/boxWasmJsInterop/nullableExternRefs.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user