[JS FIR] Support JS module system FE diagnostics

Support CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM diagnostic
^KT-59377 Fixed

Support CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM diagnostic
^KT-59381 Fixed

Support CALL_FROM_UMD_MUST_BE_JS_MODULE_AND_JS_NON_MODULE diagnostic
^KT-59417 Fixed
This commit is contained in:
Alexander Korepanov
2023-07-13 15:30:04 +02:00
committed by Space Team
parent 30b012839c
commit 08d158f901
24 changed files with 319 additions and 169 deletions
@@ -1,29 +0,0 @@
// MODULE: m1
// FILE: a.kt
package foo
import kotlin.js.*
@JsModule("A")
external object A {
fun f(): Int
val g: Int
}
@JsNonModule
external open class B {
fun foo(): Int
}
// MODULE: m2(m1)
// MODULE_KIND: UMD
// FILE: c.kt
package bar
import foo.*
fun box() {
A.f()+A.g
B()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: m1
// FILE: a.kt
package foo
@@ -1,61 +0,0 @@
// MODULE: m1
// FILE: a.kt
package foo
import kotlin.js.*
@JsModule("A")
external object A {
fun f(): Int
val g: Int
}
@JsModule("B")
external open class B {
fun foo(): Int
class Nested
}
@JsModule("bar")
external fun bar(): Unit
// MODULE: m2(m1)
// FILE: b.kt
// TODO: it's hard to test @JsNonModule on file from an external module
@file:JsModule("foo")
package foo
external fun baz(): Unit
// FILE: c.kt
package bar
import foo.*
fun box() {
A.f()+A.g
B()
bar()
baz()
println(::bar.name)
println(::baz.name)
println(A::f.name)
B.Nested()
boo<B?>(null)
boo(null as B?)
boo<B.Nested?>(null)
println(B::class)
println(B.Nested::class)
}
external class DerivedB : B
inline fun <reified T> boo(x: T) {
println("${T::class.simpleName}: $x")
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: m1
// FILE: a.kt
package foo
@@ -52,10 +53,13 @@ fun box() {
println(<!CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM!>B::class<!>)
println(<!CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM!>B.Nested::class<!>)
val x: Any = 1
println(x is B)
}
external class DerivedB : <!CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM!>B<!>
inline fun <reified T> boo(x: T) {
println("${T::class.simpleName}: $x")
}
}
@@ -1,53 +0,0 @@
// MODULE: m1
// FILE: a.kt
package foo
import kotlin.js.*
@JsNonModule
external object A {
fun f(): Int
val g: Int
}
@JsNonModule
external open class B {
fun foo(): Int
class Nested
}
@JsNonModule
external fun bar(): Unit
// MODULE: m2(m1)
// MODULE_KIND: AMD
// TODO: it's hard to test @JsNonModule on file from an external module
// FILE: c.kt
package bar
import foo.*
fun box() {
A.f()+A.g
B()
bar()
B.Nested()
println(::bar.name)
println(A::f.name)
boo<B?>(null)
boo(null as B?)
boo<B.Nested?>(null)
println(B::class)
println(B.Nested::class)
}
external class DerivedB : B
inline fun <reified T> boo(x: T) {
println("${T::class.simpleName}: $x")
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// MODULE: m1
// FILE: a.kt
package foo
@@ -44,10 +45,13 @@ fun box() {
println(<!CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM!>B::class<!>)
println(<!CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM!>B.Nested::class<!>)
val x: Any = 1
println(x is B)
}
external class DerivedB : <!CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM!>B<!>
inline fun <reified T> boo(x: T) {
println("${T::class.simpleName}: $x")
}
}