[K/JS] Implement file merging for clashed file during per-file compilation

This commit is contained in:
Artem Kobzar
2023-09-14 13:14:15 +00:00
committed by Space Team
parent 337054ba92
commit 878452bd2b
43 changed files with 529 additions and 277 deletions
@@ -0,0 +1,35 @@
// DONT_TARGET_EXACT_BACKEND: JS
// ES_MODULES
// MODULE: name_clash
// FILE: test1/lib.kt
package foo
@JsExport
open class A<T> {
open fun foo(value: T): T = value
}
// FILE: test2/lib.kt
package foo
@JsExport
class B: A<String>() {
override fun foo(value: String): String = value
}
// FILE: entry.mjs
// ENTRY_ES_MODULE
import { A, B } from "./fileNameClash-name_clash_v5.mjs";
export function box() {
var a = new A()
var aFoo = a.foo("ok")
if (aFoo != "ok") return "fail 1"
var b = new B()
var bFoo = b.foo("ok")
if (bFoo != "ok") return "fail 2"
return "OK"
}
@@ -0,0 +1,3 @@
package foo
fun test1() = test2()
@@ -0,0 +1,4 @@
package foo
@JsExport
fun test1() = test2()
@@ -0,0 +1,3 @@
package foo
fun test1() = "OK"
@@ -0,0 +1,5 @@
@file:JsFileName("f1")
package foo
fun test2() = "OK"
@@ -0,0 +1,6 @@
@file:JsFileName("f1")
package foo
@JsExport
fun test2() = "OK"
@@ -0,0 +1,3 @@
package foo
fun test2() = "OK"
@@ -0,0 +1,22 @@
STEP 0:
added file: f1.kt
STEP 1:
modifications:
U : f1.1.kt -> f1.kt
U : f2.1.kt -> f2.kt
modified ir: f1.kt
added file: f2.kt
STEP 2:
modifications:
U : f2.2.kt -> f2.kt
modified ir: f2.kt
updated imports: f1.kt
STEP 3:
modifications:
U : f1.3.kt -> f1.kt
modified ir: f1.kt
STEP 4:
modifications:
U : f2.4.kt -> f2.kt
modified ir: f2.kt
updated imports: f1.kt
@@ -0,0 +1,3 @@
import foo.test1
fun box() = test1()
@@ -0,0 +1,12 @@
STEP 0:
dependencies: lib
added file: m.kt
STEP 1:
dependencies: lib
STEP 2:
dependencies: lib
STEP 3:
dependencies: lib
updated imports: m.kt
STEP 4:
dependencies: lib
@@ -0,0 +1,22 @@
MODULES: lib, main
STEP 0:
libs: lib, main
dirty js modules: main, lib
dirty js files: lib/foo/f1, main/m, main/m.export, main
STEP 1:
libs: lib, main
dirty js modules: lib
dirty js files: lib/foo/f1
STEP 2:
libs: lib, main
dirty js modules: lib
dirty js files: lib/foo/f1, lib/foo/f1.export, lib
STEP 3:
libs: lib, main
dirty js modules: lib, main
dirty js files: lib/foo/f1, lib/foo/f1.export, main/m
STEP 4:
libs: lib, main
dirty js modules: lib
dirty js files: lib/foo/f1, lib/foo/f2, lib/foo/f1.export