Properly rename local name aliases when merging JS fragments together
This commit is contained in:
@@ -4115,6 +4115,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("sameNameOfDeclarationsInSameModule.kt")
|
||||||
|
public void testSameNameOfDeclarationsInSameModule() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inline/sameNameOfDeclarationsInSameModule.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("severalClosures.kt")
|
@TestMetadata("severalClosures.kt")
|
||||||
public void testSeveralClosures() throws Exception {
|
public void testSeveralClosures() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inline/severalClosures.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inline/severalClosures.kt");
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.js.backend.ast.*
|
|||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.coroutineMetadata
|
import org.jetbrains.kotlin.js.backend.ast.metadata.coroutineMetadata
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedPackage
|
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedPackage
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedTag
|
import org.jetbrains.kotlin.js.backend.ast.metadata.exportedTag
|
||||||
|
import org.jetbrains.kotlin.js.backend.ast.metadata.localAlias
|
||||||
import org.jetbrains.kotlin.js.translate.context.Namer
|
import org.jetbrains.kotlin.js.translate.context.Namer
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||||
import org.jetbrains.kotlin.js.translate.utils.createPrototypeStatements
|
import org.jetbrains.kotlin.js.translate.utils.createPrototypeStatements
|
||||||
@@ -141,7 +142,9 @@ class Merger(private val rootFunction: JsFunction, val internalModuleName: JsNam
|
|||||||
override fun visitElement(node: JsNode) {
|
override fun visitElement(node: JsNode) {
|
||||||
super.visitElement(node)
|
super.visitElement(node)
|
||||||
if (node is HasName) {
|
if (node is HasName) {
|
||||||
node.name = node.name?.let { name -> rename(name) }
|
val oldName = node.name
|
||||||
|
node.name = oldName?.let { rename(it) }
|
||||||
|
node.name?.localAlias = oldName?.localAlias?.let { rename(it) }
|
||||||
}
|
}
|
||||||
if (node is JsFunction) {
|
if (node is JsFunction) {
|
||||||
val coroutineMetadata = node.coroutineMetadata
|
val coroutineMetadata = node.coroutineMetadata
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 996
|
||||||
|
fun foo(x: Int) = "int: $x"
|
||||||
|
|
||||||
|
fun foo(x: String) = "string: $x"
|
||||||
|
|
||||||
|
inline fun bar(x: Int) = foo(x)
|
||||||
|
|
||||||
|
inline fun bar(x: String) = foo(x)
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a = bar(23)
|
||||||
|
if (a != "int: 23") return "fail1: $a"
|
||||||
|
|
||||||
|
val b = bar("qqq")
|
||||||
|
if (b != "string: qqq") return "fail2: $b"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user