Files
kotlin-fork/compiler/testData/diagnostics/testsWithJsStdLib/name/topLevelMethodAndJsNameConstructor.kt
T
Alexander Korepanov 5da4d31d37 [JS FIR] Rework JS_NAME_CLASH diagnostic for constructors
- Fix a false positive JS_NAME_CLASH report on constructors
   from different classes but with the same JsName.
 - Allow the same JsName for class constructors and other top-level
   declarations. This behavior differs from K1, but it is correct
   since there is no real name clash in the generated JS code.

^KT-64867 Fixed
2024-01-23 10:30:10 +00:00

12 lines
486 B
Kotlin
Vendored

// FIR_DIFFERENCE
// K1 performs a check for legacy JS BE; however, this is not relevant for IR BE because in the generated JS code,
// there is no name clash between the constructor with JsName and the other top-level declarations with the same JsName.
// Keep K1 as it is, but for K2, implement a more relevant check without the clash.
package foo
class A(val x: String) {
@JsName("aa") <!JS_NAME_CLASH!>constructor(x: Int)<!> : this("int $x")
}
<!JS_NAME_CLASH!>fun aa()<!> {}