[K/JS] Change order of exported properties definition for non ES-classes compilation ^KT-60131 Fixed
This commit is contained in:
+1
-1
@@ -245,7 +245,7 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
classBlock.statements += JsExpressionStatement(
|
classModel.postDeclarationBlock.statements += JsExpressionStatement(
|
||||||
defineProperty(classPrototypeRef, propertyName.ident, getterForwarder, setterForwarder, context.staticContext)
|
defineProperty(classPrototypeRef, propertyName.ident, getterForwarder, setterForwarder, context.staticContext)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -2289,6 +2289,12 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
|||||||
runTest("js/js.translator/testData/box/esModules/export/exportInterface.kt");
|
runTest("js/js.translator/testData/box/esModules/export/exportInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("exportInterfaceWithoutClases.kt")
|
||||||
|
public void testExportInterfaceWithoutClases() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/esModules/export/exportInterfaceWithoutClases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("exportNestedClass.kt")
|
@TestMetadata("exportNestedClass.kt")
|
||||||
public void testExportNestedClass() throws Exception {
|
public void testExportNestedClass() throws Exception {
|
||||||
@@ -2854,6 +2860,12 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
|||||||
runTest("js/js.translator/testData/box/export/exportInterface.kt");
|
runTest("js/js.translator/testData/box/export/exportInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("exportInterfaceWithoutClases.kt")
|
||||||
|
public void testExportInterfaceWithoutClases() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/export/exportInterfaceWithoutClases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("exportNestedClass.kt")
|
@TestMetadata("exportNestedClass.kt")
|
||||||
public void testExportNestedClass() throws Exception {
|
public void testExportNestedClass() throws Exception {
|
||||||
|
|||||||
+12
@@ -2395,6 +2395,12 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
|||||||
runTest("js/js.translator/testData/box/esModules/export/exportInterface.kt");
|
runTest("js/js.translator/testData/box/esModules/export/exportInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("exportInterfaceWithoutClases.kt")
|
||||||
|
public void testExportInterfaceWithoutClases() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/esModules/export/exportInterfaceWithoutClases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("exportNestedClass.kt")
|
@TestMetadata("exportNestedClass.kt")
|
||||||
public void testExportNestedClass() throws Exception {
|
public void testExportNestedClass() throws Exception {
|
||||||
@@ -2960,6 +2966,12 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
|||||||
runTest("js/js.translator/testData/box/export/exportInterface.kt");
|
runTest("js/js.translator/testData/box/export/exportInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("exportInterfaceWithoutClases.kt")
|
||||||
|
public void testExportInterfaceWithoutClases() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/export/exportInterfaceWithoutClases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("exportNestedClass.kt")
|
@TestMetadata("exportNestedClass.kt")
|
||||||
public void testExportNestedClass() throws Exception {
|
public void testExportNestedClass() throws Exception {
|
||||||
|
|||||||
+12
@@ -2289,6 +2289,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/esModules/export/exportInterface.kt");
|
runTest("js/js.translator/testData/box/esModules/export/exportInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("exportInterfaceWithoutClases.kt")
|
||||||
|
public void testExportInterfaceWithoutClases() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/esModules/export/exportInterfaceWithoutClases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("exportNestedClass.kt")
|
@TestMetadata("exportNestedClass.kt")
|
||||||
public void testExportNestedClass() throws Exception {
|
public void testExportNestedClass() throws Exception {
|
||||||
@@ -2854,6 +2860,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/export/exportInterface.kt");
|
runTest("js/js.translator/testData/box/export/exportInterface.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("exportInterfaceWithoutClases.kt")
|
||||||
|
public void testExportInterfaceWithoutClases() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/export/exportInterfaceWithoutClases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("exportNestedClass.kt")
|
@TestMetadata("exportNestedClass.kt")
|
||||||
public void testExportNestedClass() throws Exception {
|
public void testExportNestedClass() throws Exception {
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
// KT-60131
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
// RUN_PLAIN_BOX_FUNCTION
|
||||||
|
// DONT_TARGET_EXACT_BACKEND: JS
|
||||||
|
// ES_MODULES
|
||||||
|
|
||||||
|
// MODULE: export_interface
|
||||||
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
interface BaseInterface {
|
||||||
|
val prop: String
|
||||||
|
}
|
||||||
|
|
||||||
|
class Impl : BaseClass("foobar")
|
||||||
|
|
||||||
|
open class BaseClass(private val _prop: String) : BaseInterface {
|
||||||
|
final override val prop: String get() = _prop
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
fun getImpl(): BaseInterface = Impl()
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
fun getBase(): BaseInterface = BaseClass("base")
|
||||||
|
|
||||||
|
// FILE: main.mjs
|
||||||
|
// ENTRY_ES_MODULE
|
||||||
|
import { getBase, getImpl } from "./exportInterfaceWithoutClases-export_interface_v5.mjs"
|
||||||
|
|
||||||
|
export function box() {
|
||||||
|
if (getBase().prop != "base") return "fail 1";
|
||||||
|
if (getImpl().prop != "foobar") return "fail 2";
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// KT-60131
|
||||||
|
// IGNORE_BACKEND: JS
|
||||||
|
// RUN_PLAIN_BOX_FUNCTION
|
||||||
|
// INFER_MAIN_MODULE
|
||||||
|
// SKIP_DCE_DRIVEN
|
||||||
|
|
||||||
|
// MODULE: export_interface
|
||||||
|
// FILE: lib.kt
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
interface BaseInterface {
|
||||||
|
val prop: String
|
||||||
|
}
|
||||||
|
|
||||||
|
class Impl : BaseClass("foobar")
|
||||||
|
|
||||||
|
open class BaseClass(private val _prop: String) : BaseInterface {
|
||||||
|
final override val prop: String get() = _prop
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
fun getImpl(): BaseInterface = Impl()
|
||||||
|
|
||||||
|
@JsExport
|
||||||
|
fun getBase(): BaseInterface = BaseClass("base")
|
||||||
|
|
||||||
|
// FILE: test.js
|
||||||
|
function box() {
|
||||||
|
if (this["export_interface"].getBase().prop != "base") return "fail 1";
|
||||||
|
if (this["export_interface"].getImpl().prop != "foobar") return "fail 2";
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user