[JS IR] Respect JsExport while assigning stable names
see https://youtrack.jetbrains.com/issue/KT-43404
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
$kotlin_test_internal$.beginModule();
|
||||
|
||||
module.exports = function() {
|
||||
var Point = require("JS_TESTS").api.Point;
|
||||
var p = new Point(3, 7);
|
||||
|
||||
return {
|
||||
"res": p.copy(13, 11).toString()
|
||||
};
|
||||
};
|
||||
|
||||
$kotlin_test_internal$.endModule("lib");
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// MODULE_KIND: COMMON_JS
|
||||
// SKIP_MINIFICATION
|
||||
|
||||
// FILE: api.kt
|
||||
package api
|
||||
|
||||
@JsExport
|
||||
data class Point(val x: Int, val y: Int) {
|
||||
override fun toString(): String = "[${x}::${y}]"
|
||||
}
|
||||
|
||||
// we need his class to make sure that there's more than one ping method in existence - due to peculiarities of current namer otherwise test can pass but JsExport won't be actually respected
|
||||
data class AltPoint(val x: Int, val y: Int)
|
||||
|
||||
// FILE: main.kt
|
||||
external interface JsResult {
|
||||
val res: String
|
||||
}
|
||||
|
||||
@JsModule("lib")
|
||||
external fun jsBox(): JsResult
|
||||
|
||||
fun box(): String {
|
||||
val res = jsBox().res
|
||||
if (res != "[13::11]") {
|
||||
return "Fail1: ${res}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
$kotlin_test_internal$.beginModule();
|
||||
|
||||
module.exports = function() {
|
||||
var A = require("JS_TESTS").api.A;
|
||||
var B = require("JS_TESTS").api.B;
|
||||
|
||||
return {
|
||||
"res": (new A().ping()) + (new B().pong())
|
||||
};
|
||||
};
|
||||
|
||||
$kotlin_test_internal$.endModule("lib");
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// MODULE_KIND: COMMON_JS
|
||||
// SKIP_MINIFICATION
|
||||
|
||||
// FILE: api.kt
|
||||
package api
|
||||
|
||||
@JsExport
|
||||
class A() {
|
||||
fun ping() = "ping"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class B() {
|
||||
@JsName("pong")
|
||||
fun ping() = "pong"
|
||||
}
|
||||
|
||||
// we need his class to make sure that there's more than one ping method in existence - due to peculiarities of current namer otherwise test can pass but JsExport won't be actually respected
|
||||
class C() {
|
||||
fun ping() = "pong"
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
external interface JsResult {
|
||||
val res: String
|
||||
}
|
||||
|
||||
@JsModule("lib")
|
||||
external fun jsBox(): JsResult
|
||||
|
||||
fun box(): String {
|
||||
val res = jsBox().res
|
||||
if (res != "pingpong") {
|
||||
return "Fail: ${res}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user