[JS IR] Support object declaration export
Fixes KT-39117 and KT-39367
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1290
|
||||
|
||||
// TODO: Support JsExport on object declarations: KT-39117
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
|
||||
@JsExport
|
||||
object A {
|
||||
@JsName("js_method") fun f() = "method"
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1291
|
||||
|
||||
// TODO: Support JsExport on object declarations: KT-39117
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
|
||||
@JsExport
|
||||
object A {
|
||||
@JsName("js_f") fun f(x: Int) = "f($x)"
|
||||
|
||||
@@ -42,5 +42,12 @@ declare namespace JS_TESTS {
|
||||
_varCustom: number;
|
||||
_varCustomWithField: number;
|
||||
}
|
||||
const O0: {
|
||||
};
|
||||
const O: {
|
||||
readonly x: number;
|
||||
foo(): number;
|
||||
};
|
||||
function takesO(o: typeof foo.O): number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,4 +82,15 @@ class A4 {
|
||||
var _varCustomWithField: Int = 1
|
||||
get() = field * 10
|
||||
set(value) { field = value * 10 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
object O0
|
||||
|
||||
object O {
|
||||
val x = 10
|
||||
fun foo() = 20
|
||||
}
|
||||
|
||||
fun takesO(o: O): Int =
|
||||
O.x + O.foo()
|
||||
+5
@@ -20,6 +20,8 @@ var A3 = JS_TESTS.foo.A3;
|
||||
var _valCustom = JS_TESTS.foo._valCustom;
|
||||
var _valCustomWithField = JS_TESTS.foo._valCustomWithField;
|
||||
var A4 = JS_TESTS.foo.A4;
|
||||
var O = JS_TESTS.foo.O;
|
||||
var takesO = JS_TESTS.foo.takesO;
|
||||
function assert(condition) {
|
||||
if (!condition) {
|
||||
throw "Assertion failed";
|
||||
@@ -75,5 +77,8 @@ function box() {
|
||||
assert(a4._varCustomWithField === 10);
|
||||
a4._varCustomWithField = 10;
|
||||
assert(a4._varCustomWithField === 1000);
|
||||
assert(O.x === 10);
|
||||
assert(O.foo() === 20);
|
||||
assert(takesO(O) === 30);
|
||||
return "OK";
|
||||
}
|
||||
|
||||
+6
@@ -20,6 +20,8 @@ import A3 = JS_TESTS.foo.A3;
|
||||
import _valCustom = JS_TESTS.foo._valCustom;
|
||||
import _valCustomWithField = JS_TESTS.foo._valCustomWithField;
|
||||
import A4 = JS_TESTS.foo.A4;
|
||||
import O = JS_TESTS.foo.O;
|
||||
import takesO = JS_TESTS.foo.takesO;
|
||||
|
||||
function assert(condition: boolean) {
|
||||
if (!condition) {
|
||||
@@ -86,5 +88,9 @@ function box(): string {
|
||||
a4._varCustomWithField = 10;
|
||||
assert(a4._varCustomWithField === 1000);
|
||||
|
||||
assert(O.x === 10);
|
||||
assert(O.foo() === 20);
|
||||
assert(takesO(O) === 30);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@@ -30,5 +30,10 @@ declare namespace JS_TESTS {
|
||||
class FC extends foo.OC {
|
||||
constructor();
|
||||
}
|
||||
const O1: {
|
||||
} & foo.OC;
|
||||
const O2: {
|
||||
foo(): number;
|
||||
} & foo.OC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,10 @@ open class OC(
|
||||
private fun privateFun(): String = "privateFun"
|
||||
}
|
||||
|
||||
final class FC : OC(true, "FC")
|
||||
final class FC : OC(true, "FC")
|
||||
|
||||
object O1 : OC(true, "O1")
|
||||
|
||||
object O2 : OC(true, "O2") {
|
||||
fun foo(): Int = 10
|
||||
}
|
||||
+12
-2
@@ -15,6 +15,8 @@ var __extends = (this && this.__extends) || (function () {
|
||||
var OC = JS_TESTS.foo.OC;
|
||||
var AC = JS_TESTS.foo.AC;
|
||||
var FC = JS_TESTS.foo.FC;
|
||||
var O1 = JS_TESTS.foo.O1;
|
||||
var O2 = JS_TESTS.foo.O2;
|
||||
var Impl = /** @class */ (function (_super) {
|
||||
__extends(Impl, _super);
|
||||
function Impl() {
|
||||
@@ -24,12 +26,12 @@ var Impl = /** @class */ (function (_super) {
|
||||
};
|
||||
Object.defineProperty(Impl.prototype, "acAbstractProp", {
|
||||
get: function () { return "Impl"; },
|
||||
enumerable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Impl.prototype, "y", {
|
||||
get: function () { return true; },
|
||||
enumerable: true,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Impl;
|
||||
@@ -56,5 +58,13 @@ function box() {
|
||||
if (fc.acAbstractProp !== "FC")
|
||||
return "Fail 6";
|
||||
fc.z(10);
|
||||
if (O1.y !== true || O2.y !== true)
|
||||
return "Fail 7";
|
||||
if (O1.acAbstractProp != "O1")
|
||||
return "Fail 8";
|
||||
if (O2.acAbstractProp != "O2")
|
||||
return "Fail 9";
|
||||
if (O2.foo() != 10)
|
||||
return "Fail 10";
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import OC = JS_TESTS.foo.OC;
|
||||
import AC = JS_TESTS.foo.AC;
|
||||
import FC = JS_TESTS.foo.FC;
|
||||
import O1 = JS_TESTS.foo.O1;
|
||||
import O2 = JS_TESTS.foo.O2;
|
||||
|
||||
class Impl extends AC {
|
||||
z(z: number): void {
|
||||
@@ -29,5 +31,10 @@ function box(): string {
|
||||
if (fc.acAbstractProp !== "FC") return "Fail 6";
|
||||
fc.z(10);
|
||||
|
||||
if (O1.y !== true || O2.y !== true) return "Fail 7";
|
||||
if (O1.acAbstractProp != "O1") return "Fail 8";
|
||||
if (O2.acAbstractProp != "O2") return "Fail 9";
|
||||
if (O2.foo() != 10) return "Fail 10";
|
||||
|
||||
return "OK";
|
||||
}
|
||||
Reference in New Issue
Block a user