[FIR JS] Support JS_NAME_CLASH and JS_FAKE_NAME_CLASH diagnostics

^KT-59425 Fixed
^KT-59370 Fixed
This commit is contained in:
Alexander Korepanov
2023-08-10 11:45:08 +02:00
committed by Space Team
parent 5ac277d058
commit 6bb939c6cb
50 changed files with 452 additions and 196 deletions
@@ -1,18 +0,0 @@
interface I {
fun foo()
}
interface J {
@JsName("bar")
fun foo()
}
interface K : I, J {
override fun foo()
}
interface L : K {
override fun foo()
fun bar()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface I {
fun foo()
}
@@ -1,5 +0,0 @@
package foo
class A(val x: Int)
fun A() {}
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
package foo
class <!JS_NAME_CLASH!>A(val x: Int)<!>
<!JS_NAME_CLASH!>fun A()<!> {}
<!JS_NAME_CLASH!>fun A()<!> {}
@@ -1,7 +0,0 @@
package foo
class A {
fun bar() = 23
val bar = 23
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package foo
class A {
@@ -1,23 +0,0 @@
interface A {
@JsName("foo") fun f()
}
interface B {
@JsName("foo") fun g()
}
class C : A, B {
override fun f() {}
override fun g() {}
}
abstract class D : A, B
open class E {
open fun f() {}
open fun g() {}
}
class F : E(), A, B
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface A {
@JsName("foo") fun f()
}
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case is only relevant for the JS Legacy BE and is not applicable to the JS IR backend,
// as the IR BE can resolve such name collisions.
package foo
class A
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case is only relevant for the JS Legacy BE and is not applicable to the JS IR backend,
// as the IR BE can resolve such name collisions.
package foo
class A
@@ -5,4 +8,4 @@ class A
<!JS_NAME_CLASH!>fun A.get_bar()<!> = 23
val A.bar: Int
<!JS_NAME_CLASH!>get()<!> = 42
<!JS_NAME_CLASH!>get()<!> = 42
@@ -1,9 +0,0 @@
package foo
open class Super {
fun foo() = 23
}
class Sub : Super() {
@JsName("foo") fun bar() = 42
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package foo
open class Super {
@@ -1,5 +0,0 @@
package foo
@JsName("x") fun foo(x: Int) = x
@JsName("x") fun bar() = 42
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
package foo
<!JS_NAME_CLASH!>@JsName("x") fun foo(x: Int)<!> = x
<!JS_NAME_CLASH!>@JsName("x") fun bar()<!> = 42
<!JS_NAME_CLASH!>@JsName("x") fun bar()<!> = 42
@@ -1,5 +0,0 @@
package foo
@JsName("bar") fun foo(x: Int) = x
fun bar() = 42
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
package foo
<!JS_NAME_CLASH!>@JsName("bar") fun foo(x: Int)<!> = x
<!JS_NAME_CLASH!>fun bar()<!> = 42
<!JS_NAME_CLASH!>fun bar()<!> = 42
@@ -2,6 +2,6 @@ package foo
class A {
var x: Int
@JsName("xx") get() = 0
@JsName("xx") set(value) {}
<!JS_NAME_CLASH!>@JsName("xx") get()<!> = 0
<!JS_NAME_CLASH!>@JsName("xx") set(value)<!> {}
}
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case is only relevant for the JS Legacy BE and is not applicable to the JS IR backend,
// as the IR BE can resolve such name collisions. Furthermore, the IR BE mangles names differently.
package foo
fun bar(x: Int) = x
@@ -1,5 +1,8 @@
// FIR_DIFFERENCE
// This case is only relevant for the JS Legacy BE and is not applicable to the JS IR backend,
// as the IR BE can resolve such name collisions. Furthermore, the IR BE mangles names differently.
package foo
<!JS_NAME_CLASH!>fun bar(x: Int)<!> = x
<!JS_NAME_CLASH!>fun `bar_za3lpa$`()<!> = 42
<!JS_NAME_CLASH!>fun `bar_za3lpa$`()<!> = 42
@@ -1,21 +0,0 @@
interface I {
@JsName("bar")
fun foo()
@JsName("foo")
fun bar()
}
interface J {
fun foo()
fun bar()
}
class A : I, J {
// Duplicate diagnostics are expected here, since `bar()` function gets both `foo` and `bar` names and clashes with both
// names of `foo()` function.
override fun bar() {}
override fun foo() {}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
interface I {
@JsName("bar")
fun foo()
@@ -1,9 +0,0 @@
external open class A {
open fun f(x: Int): Unit
open fun f(x: String): Unit
}
class InheritClass : A() {
override fun f(x: Int): Unit { }
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
external open class A {
open fun f(x: Int): Unit
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case can't be checked using FIR. It is checked later on klib serialization.
// FILE: foo.kt
package foo
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case can't be checked using FIR. It is checked later on klib serialization.
// FILE: foo.kt
package foo
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case can't be checked using FIR. It is checked later on klib serialization.
// FILE: foo.kt
package foo
@@ -1,3 +1,6 @@
// FIR_DIFFERENCE
// This case can't be checked using FIR. It is checked later on klib serialization.
// FILE: foo.kt
package foo
@@ -1,5 +0,0 @@
package foo
@JsName("bar") private fun foo(x: Int) = x
fun bar() = 42
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
package foo
<!JS_NAME_CLASH!>@JsName("bar") private fun foo(x: Int)<!> = x
<!JS_NAME_CLASH!>fun bar()<!> = 42
<!JS_NAME_CLASH!>fun bar()<!> = 42
@@ -1,9 +0,0 @@
package foo
interface I {
fun foo() = 23
}
class Sub : I {
var foo = 42
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package foo
interface I {
@@ -1,9 +0,0 @@
package foo
open class Super {
val foo = 23
}
class Sub : Super() {
fun foo() = 42
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
package foo
open class Super {
@@ -1,7 +0,0 @@
package foo
class A(val x: String) {
@JsName("aa") constructor(x: Int) : this("int $x")
}
fun aa() {}
@@ -1,7 +1,8 @@
// FIR_IDENTICAL
package foo
class A(val x: String) {
@JsName("aa") <!JS_NAME_CLASH!>constructor(x: Int)<!> : this("int $x")
}
<!JS_NAME_CLASH!>fun aa()<!> {}
<!JS_NAME_CLASH!>fun aa()<!> {}
@@ -1,5 +0,0 @@
package foo
fun bar() = 23
val bar = 32
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
package foo
<!JS_NAME_CLASH!>fun bar()<!> = 23
<!JS_NAME_CLASH!>val bar<!> = 32
<!JS_NAME_CLASH!>val bar<!> = 32