[K/JS] Generate tests for K2 + ES-classes compilation
This commit is contained in:
+5
-1
@@ -35,6 +35,7 @@ object ES6_SYNTHETIC_EXPORT_CONSTRUCTOR: IrDeclarationOriginImpl("ES6_SYNTHETIC_
|
||||
object ES6_PRIMARY_CONSTRUCTOR_REPLACEMENT : IrDeclarationOriginImpl("ES6_PRIMARY_CONSTRUCTOR_REPLACEMENT")
|
||||
object ES6_INIT_FUNCTION : IrDeclarationOriginImpl("ES6_INIT_FUNCTION")
|
||||
object ES6_DELEGATING_CONSTRUCTOR_REPLACEMENT : IrStatementOriginImpl("ES6_DELEGATING_CONSTRUCTOR_REPLACEMENT")
|
||||
object ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT : IrDeclarationOriginImpl("ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT")
|
||||
|
||||
val IrDeclaration.isEs6ConstructorReplacement: Boolean
|
||||
get() = origin == ES6_CONSTRUCTOR_REPLACEMENT || origin == ES6_PRIMARY_CONSTRUCTOR_REPLACEMENT
|
||||
@@ -54,6 +55,9 @@ val IrFunctionAccessExpression.isInitCall: Boolean
|
||||
val IrDeclaration.isSyntheticConstructorForExport: Boolean
|
||||
get() = origin == ES6_SYNTHETIC_EXPORT_CONSTRUCTOR
|
||||
|
||||
val IrDeclaration.isEs6DelegatingConstructorCallReplacement: Boolean
|
||||
get() = origin == ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT
|
||||
|
||||
class ES6ConstructorLowering(val context: JsIrBackendContext) : DeclarationTransformer {
|
||||
private var IrConstructor.constructorFactory by context.mapping.secondaryConstructorToFactory
|
||||
|
||||
@@ -161,7 +165,7 @@ class ES6ConstructorLowering(val context: JsIrBackendContext) : DeclarationTrans
|
||||
parent = this,
|
||||
name = Namer.SYNTHETIC_RECEIVER_NAME,
|
||||
initializer = initializer,
|
||||
origin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||
origin = ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -339,10 +339,10 @@ class EnumEntryInstancesBodyLowering(val context: JsCommonBackendContext) : Body
|
||||
if (enum.isInstantiableEnum) {
|
||||
val entry = enum.declarations.findIsInstanceAnd<IrEnumEntry> { it.correspondingClass === entryClass }!!
|
||||
|
||||
//In ES6 using `this` before superCall is unavailable, so
|
||||
//need to find superCall and put `instance = this` after it
|
||||
// In ES6 using `this` before superCall is unavailable, so
|
||||
// need to find superCall and put `instance = this` after it
|
||||
val index = (irBody as IrBlockBody).statements
|
||||
.indexOfFirst { it is IrTypeOperatorCall && it.argument is IrDelegatingConstructorCall } + 1
|
||||
.indexOfFirst { it is IrDelegatingConstructorCall || it is IrTypeOperatorCall && it.argument is IrDelegatingConstructorCall } + 1
|
||||
|
||||
irBody.statements.add(index, context.createIrBuilder(container.symbol).run {
|
||||
irSetField(null, entry.correspondingField!!, irGet(entryClass.thisReceiver!!))
|
||||
|
||||
+22
-20
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.getOrPut
|
||||
import org.jetbrains.kotlin.backend.common.ir.isPure
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.isObjectInstanceField
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.isObjectInstanceGetter
|
||||
@@ -24,21 +23,15 @@ class PurifyObjectInstanceGettersLowering(val context: JsCommonBackendContext) :
|
||||
private var IrClass.instanceField by context.mapping.objectToInstanceField
|
||||
|
||||
override fun transformFlat(declaration: IrDeclaration): List<IrDeclaration>? {
|
||||
if (
|
||||
!declaration.isObjectInstanceGetter() &&
|
||||
!declaration.isObjectInstanceField() &&
|
||||
!declaration.isObjectConstructor()
|
||||
) return null
|
||||
|
||||
return when (declaration) {
|
||||
is IrSimpleFunction -> declaration.purifyObjectGetterIfPossible()
|
||||
is IrField -> declaration.purifyObjectInstanceFieldIfPossible()
|
||||
is IrConstructor -> declaration.removeInstanceFieldInitializationIfPossible()
|
||||
else -> error("Unexpected IR type ${declaration::class.qualifiedName}")
|
||||
return when {
|
||||
(declaration is IrFunction && declaration.isObjectConstructor()) -> declaration.removeInstanceFieldInitializationIfPossible()
|
||||
(declaration is IrSimpleFunction && declaration.isObjectInstanceGetter()) -> declaration.purifyObjectGetterIfPossible()
|
||||
(declaration is IrField && declaration.isObjectInstanceField()) -> declaration.purifyObjectInstanceFieldIfPossible()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrConstructor.removeInstanceFieldInitializationIfPossible(): List<IrDeclaration>? {
|
||||
private fun IrFunction.removeInstanceFieldInitializationIfPossible(): List<IrDeclaration>? {
|
||||
if (parentAsClass.isPureObject()) {
|
||||
(body as? IrBlockBody)?.statements?.removeIf {
|
||||
it is IrSetField && it.symbol.owner.isObjectInstanceField()
|
||||
@@ -70,30 +63,36 @@ class PurifyObjectInstanceGettersLowering(val context: JsCommonBackendContext) :
|
||||
val objectToCreate = type.classOrNull?.owner ?: return null
|
||||
|
||||
if (objectToCreate.isPureObject()) {
|
||||
val objectConstructor = objectToCreate.primaryConstructor ?: error("Object should contain a primary constructor")
|
||||
initializer = IrExpressionBodyImpl(JsIrBuilder.buildConstructorCall(objectConstructor.symbol))
|
||||
initializer = IrExpressionBodyImpl(
|
||||
objectToCreate.primaryConstructor?.let { JsIrBuilder.buildConstructorCall(it.symbol) }
|
||||
?: objectToCreate.primaryConstructorReplacement?.let { JsIrBuilder.buildCall(it.symbol) }
|
||||
?: error("Object should contain a primary constructor")
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun IrDeclaration.isObjectConstructor(): Boolean {
|
||||
return this is IrConstructor && parentAsClass.isObject
|
||||
return (this is IrConstructor || isEs6ConstructorReplacement) && parentAsClass.isObject
|
||||
}
|
||||
|
||||
private fun IrClass.isPureObject(): Boolean {
|
||||
return context.mapping.objectsWithPureInitialization.getOrPut(this) {
|
||||
superClass == null && primaryConstructor?.body?.statements?.all { it.isPureStatementForObjectInitialization(this@isPureObject) } != false
|
||||
val constructor = primaryConstructor ?: primaryConstructorReplacement
|
||||
superClass == null && constructor?.body?.statements?.all { it.isPureStatementForObjectInitialization(this@isPureObject) } != false
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrStatement.isPureStatementForObjectInitialization(owner: IrClass): Boolean {
|
||||
return (
|
||||
// Only objects which don't have a class parent
|
||||
(this is IrDelegatingConstructorCall && symbol.owner.parent == context.irBuiltIns.anyClass.owner) ||
|
||||
this is IrReturn ||
|
||||
// Only objects which don't have a class parent
|
||||
(this is IrDelegatingConstructorCall && symbol.owner.parent == context.irBuiltIns.anyClass.owner) ||
|
||||
(this is IrExpression && isPure(anyVariable = true, checkFields = false, context = context)) ||
|
||||
(this is IrContainerExpression && statements.all { it.isPureStatementForObjectInitialization(owner) }) ||
|
||||
(this is IrVariable && initializer?.isPureStatementForObjectInitialization(owner) != false) ||
|
||||
(this is IrVariable && (isEs6DelegatingConstructorCallReplacement || initializer?.isPureStatementForObjectInitialization(owner) != false)) ||
|
||||
// Only fields of the objects are safe to not save an intermediate state of another class/object/global
|
||||
(this is IrGetField && receiver?.isPureStatementForObjectInitialization(owner) == true) ||
|
||||
(this is IrSetField && receiver?.isPureStatementForObjectInitialization(owner) == true && value.isPureStatementForObjectInitialization(owner)) ||
|
||||
@@ -103,4 +102,7 @@ class PurifyObjectInstanceGettersLowering(val context: JsCommonBackendContext) :
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private val IrClass.primaryConstructorReplacement: IrSimpleFunction?
|
||||
get() = findDeclaration<IrSimpleFunction> { it.isEs6PrimaryConstructorReplacement }
|
||||
}
|
||||
|
||||
+2
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.ir.backend.js.transformers.irToJs
|
||||
import org.jetbrains.kotlin.ir.util.inlineFunction
|
||||
import org.jetbrains.kotlin.ir.util.innerInlinedBlockOrThis
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.JsGenerationContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.emptyScope
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.isTheLastReturnStatementIn
|
||||
@@ -171,6 +172,7 @@ class IrElementToJsStatementTransformer : BaseIrElementToJsNodeTransformer<JsSta
|
||||
is IrDeclarationOrigin.IR_TEMPORARY_VARIABLE -> true
|
||||
is IrDeclarationOrigin.IR_TEMPORARY_VARIABLE_FOR_INLINED_PARAMETER -> true
|
||||
is IrDeclarationOrigin.IR_TEMPORARY_VARIABLE_FOR_INLINED_EXTENSION_RECEIVER -> true
|
||||
is ES6_DELEGATING_CONSTRUCTOR_CALL_REPLACEMENT -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: WASM
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND_K1: JS_IR, WASM
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6, WASM
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// WITH_REFLECT
|
||||
// WITH_STDLIB
|
||||
// FILE: J.java
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// WITH_STDLIB
|
||||
|
||||
class A(val ok: String)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
//KT-3822 Compiler crashes when use invoke convention with `this` in class which extends Function0<T>
|
||||
// IGNORE_BACKEND: JS
|
||||
// JS backend does not allow to implement Function{N} interfaces
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR, WASM
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6, WASM
|
||||
|
||||
// KT-40686
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// FILE: lib.kt
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
// IGNORE_REASON: new rules for supertypes matching are implemented only in K2
|
||||
// IGNORE_BACKEND_K2: JS_IR, WASM
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6, WASM
|
||||
// IGNORE_REASON: `JsName` in js.translator/testData/_commonFiles/testUtils.kt is invisible for some reason
|
||||
// LANGUAGE: +MultiPlatformProjects
|
||||
// ISSUE: KT-59356
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
// IGNORE_REASON: KT-59355 is fixed only in K2
|
||||
// IGNORE_BACKEND_K2: JS_IR, WASM
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6, WASM
|
||||
// IGNORE_REASON: `JsName` in js.translator/testData/_commonFiles/testUtils.kt is invisible for some reason
|
||||
// LANGUAGE: +MultiPlatformProjects
|
||||
// ISSUE: KT-59355
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
|
||||
// IllegalArgumentException: arg wrongly != this@Test5: arg=null, this@Test5=[object Object]
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// Wrong box result 'arg1 wrongly != this@Test5: arg1=Inner@1346131020, this@Test5=Test5@314569418'; Expected "OK"
|
||||
// IGNORE_BACKEND_K2: WASM
|
||||
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: WASM
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: WASM
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// K2 JS_IR MUTE_REASON: java.lang.NullPointerException at org.jetbrains.kotlin.fir.backend.Fir2IrClassifierStorage.getIrClassSymbol
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// Test that if we have two different files with the same name in the same package, KT-54028 doesn't reproduce.
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: WASM
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// CHECK_CASES_COUNT: function=crash count=2 TARGET_BACKENDS=JS
|
||||
// CHECK_CASES_COUNT: function=crash count=0 IGNORED_BACKENDS=JS
|
||||
// CHECK_IF_COUNT: function=crash count=1 TARGET_BACKENDS=JS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// CHECK_CASES_COUNT: function=doTheThing count=2 TARGET_BACKENDS=JS
|
||||
// CHECK_CASES_COUNT: function=doTheThing count=0 IGNORED_BACKENDS=JS
|
||||
// CHECK_IF_COUNT: function=doTheThing count=2 TARGET_BACKENDS=JS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// IGNORE_ERRORS
|
||||
// ERROR_POLICY: SEMANTIC
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: t.kt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// IGNORE_ERRORS
|
||||
// ERROR_POLICY: SEMANTIC
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: t.kt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// IGNORE_ERRORS
|
||||
// ERROR_POLICY: SEMANTIC
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: t.kt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// IGNORE_ERRORS
|
||||
// ERROR_POLICY: SYNTAX
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: t.kt
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// IGNORE_ERRORS
|
||||
// ERROR_POLICY: SYNTAX
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: t.kt
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// IGNORE_BACKEND_K2: WASM
|
||||
|
||||
// Partial copy of js/js.translator/testData/box/native/vararg.kt
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// ^ the order of fake overrides is different on K2
|
||||
|
||||
interface X {
|
||||
|
||||
@@ -266,16 +266,30 @@ fun Test.setUpJsBoxTests(jsEnabled: Boolean, jsIrEnabled: Boolean, firEnabled: B
|
||||
}
|
||||
if (!jsEnabled) {
|
||||
when {
|
||||
firEnabled -> {
|
||||
firEnabled && !es6Enabled -> {
|
||||
include("org/jetbrains/kotlin/js/test/fir/*")
|
||||
|
||||
exclude("org/jetbrains/kotlin/js/test/fir/FirJsES6BoxTestGenerated.class")
|
||||
exclude("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.class")
|
||||
exclude("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenInlineTestGenerated.class")
|
||||
exclude("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxErrorTestGenerated.class")
|
||||
exclude("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenWasmJsInteropTestGenerated.class")
|
||||
}
|
||||
es6Enabled -> {
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenInlineTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxErrorTestGenerated.class")
|
||||
if (firEnabled) {
|
||||
include("org/jetbrains/kotlin/js/test/fir/FirJsES6BoxTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenInlineTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxErrorTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenWasmJsInteropTestGenerated.class")
|
||||
} else {
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenInlineTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxErrorTestGenerated.class")
|
||||
|
||||
include("org/jetbrains/kotlin/incremental/JsIrES6InvalidationTestGenerated.class")
|
||||
include("org/jetbrains/kotlin/incremental/JsIrES6InvalidationTestGenerated.class")
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
include("org/jetbrains/kotlin/js/test/ir/*")
|
||||
@@ -358,6 +372,7 @@ projectTest("jsIrTest", jUnitMode = JUnitMode.JUnit5) {
|
||||
setUpJsBoxTests(jsEnabled = false, jsIrEnabled = true, firEnabled = false, es6Enabled = false)
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
projectTest("jsIrES6Test", jUnitMode = JUnitMode.JUnit5) {
|
||||
setUpJsBoxTests(jsEnabled = false, jsIrEnabled = true, firEnabled = false, es6Enabled = true)
|
||||
useJUnitPlatform()
|
||||
@@ -368,6 +383,11 @@ projectTest("jsFirTest", jUnitMode = JUnitMode.JUnit5) {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
projectTest("jsFirES6Test", jUnitMode = JUnitMode.JUnit5) {
|
||||
setUpJsBoxTests(jsEnabled = false, jsIrEnabled = true, firEnabled = true, es6Enabled = true)
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
projectTest("quickTest", jUnitMode = JUnitMode.JUnit5) {
|
||||
setUpJsBoxTests(jsEnabled = true, jsIrEnabled = false, firEnabled = false, es6Enabled = false)
|
||||
systemProperty("kotlin.js.skipMinificationTest", "true")
|
||||
|
||||
@@ -137,6 +137,10 @@ fun main(args: Array<String>) {
|
||||
model("box/", pattern = "^([^_](.+))\\.kt$", excludeDirs = listOf("es6classes"))
|
||||
}
|
||||
|
||||
testClass<AbstractFirJsES6BoxTest> {
|
||||
model("box/", pattern = "^([^_](.+))\\.kt$")
|
||||
}
|
||||
|
||||
// see todo on defining class
|
||||
// testClass<AbstractFirJsTypeScriptExportTest> {
|
||||
// model("typescript-export/", pattern = "^([^_](.+))\\.kt$")
|
||||
@@ -218,6 +222,22 @@ fun main(args: Array<String>) {
|
||||
model("codegen/boxWasmJsInterop")
|
||||
}
|
||||
|
||||
testClass<AbstractFirJsES6CodegenBoxTest> {
|
||||
model("codegen/box", excludeDirs = jvmOnlyBoxTests)
|
||||
}
|
||||
|
||||
testClass<AbstractFirJsES6CodegenBoxErrorTest> {
|
||||
model("codegen/boxError", excludeDirs = jvmOnlyBoxTests)
|
||||
}
|
||||
|
||||
testClass<AbstractFirJsES6CodegenInlineTest> {
|
||||
model("codegen/boxInline")
|
||||
}
|
||||
|
||||
testClass<AbstractFirJsES6CodegenWasmJsInteropTest> {
|
||||
model("codegen/boxWasmJsInterop")
|
||||
}
|
||||
|
||||
// see todo on AbstractFirJsSteppingTest
|
||||
// testClass<AbstractFirJsSteppingTest> {
|
||||
// model("debug/stepping")
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.jetbrains.kotlin.js.test.fir
|
||||
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.builders.*
|
||||
import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.frontend.fir.FirMetaInfoDiffSuppressor
|
||||
import org.jetbrains.kotlin.test.runners.codegen.commonFirHandlersForCodegenTest
|
||||
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
|
||||
|
||||
abstract class AbstractFirJsES6Test(
|
||||
pathToTestDir: String = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/box/",
|
||||
testGroupOutputDirPrefix: String,
|
||||
) : AbstractFirJsTest(pathToTestDir, testGroupOutputDirPrefix, TargetBackend.JS_IR_ES6) {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
with(builder) {
|
||||
defaultDirectives {
|
||||
+JsEnvironmentConfigurationDirectives.ES6_MODE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open class AbstractFirJsES6BoxTest : AbstractFirJsES6Test(
|
||||
pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/box/",
|
||||
testGroupOutputDirPrefix = "firEs6Box/"
|
||||
)
|
||||
|
||||
open class AbstractFirJsES6CodegenBoxTest : AbstractFirJsES6Test(
|
||||
pathToTestDir = "compiler/testData/codegen/box/",
|
||||
testGroupOutputDirPrefix = "codegen/firEs6Box/"
|
||||
) {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.configureFirHandlersStep {
|
||||
commonFirHandlersForCodegenTest()
|
||||
}
|
||||
|
||||
builder.useAfterAnalysisCheckers(
|
||||
::FirMetaInfoDiffSuppressor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractFirJsES6CodegenBoxErrorTest : AbstractFirJsES6Test(
|
||||
pathToTestDir = "compiler/testData/codegen/boxError/",
|
||||
testGroupOutputDirPrefix = "codegen/firEs6BoxError/"
|
||||
)
|
||||
|
||||
open class AbstractFirJsES6CodegenInlineTest : AbstractFirJsES6Test(
|
||||
pathToTestDir = "compiler/testData/codegen/boxInline/",
|
||||
testGroupOutputDirPrefix = "codegen/firEs6BoxInline/"
|
||||
)
|
||||
|
||||
open class AbstractFirJsES6CodegenWasmJsInteropTest : AbstractFirJsES6Test(
|
||||
pathToTestDir = "compiler/testData/codegen/wasmJsInterop",
|
||||
testGroupOutputDirPrefix = "codegen/wasmJsInteropJsEs6"
|
||||
)
|
||||
@@ -29,8 +29,9 @@ import java.lang.Boolean.getBoolean
|
||||
open class AbstractFirJsTest(
|
||||
pathToTestDir: String = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/box/",
|
||||
testGroupOutputDirPrefix: String,
|
||||
targetBackend: TargetBackend = TargetBackend.JS_IR
|
||||
) : AbstractJsBlackBoxCodegenTestBase<FirOutputArtifact, IrBackendInput, BinaryArtifacts.KLib>(
|
||||
FrontendKinds.FIR, TargetBackend.JS_IR, pathToTestDir, testGroupOutputDirPrefix, skipMinification = true
|
||||
FrontendKinds.FIR, targetBackend, pathToTestDir, testGroupOutputDirPrefix, skipMinification = true
|
||||
) {
|
||||
override val frontendFacade: Constructor<FrontendFacade<FirOutputArtifact>>
|
||||
get() = ::FirFrontendFacade
|
||||
|
||||
+11067
File diff suppressed because it is too large
Load Diff
Generated
+131
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.test.fir;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/boxError")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirJsES6CodegenBoxErrorTestGenerated extends AbstractFirJsES6CodegenBoxErrorTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInBoxError() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true, "compileKotlinAgainstKotlin");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/boxError/semantic")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Semantic {
|
||||
@Test
|
||||
public void testAllFilesPresentInSemantic() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError/semantic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("castToErrorType.kt")
|
||||
public void testCastToErrorType() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/castToErrorType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("catchErrorType.kt")
|
||||
public void testCatchErrorType() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/catchErrorType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("evaluationOrder.kt")
|
||||
public void testEvaluationOrder() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/evaluationOrder.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mismatchTypeParameters.kt")
|
||||
public void testMismatchTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("missedBody.kt")
|
||||
public void testMissedBody() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/missedBody.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedNonInline.kt")
|
||||
public void testReifiedNonInline() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedWithWrongArguments.kt")
|
||||
public void testReifiedWithWrongArguments() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/reifiedWithWrongArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeMismatch.kt")
|
||||
public void testTypeMismatch() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/typeMismatch.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unmatchedArguments.kt")
|
||||
public void testUnmatchedArguments() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unresolvedFunctionReferece.kt")
|
||||
public void testUnresolvedFunctionReferece() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/boxError/syntax")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Syntax {
|
||||
@Test
|
||||
public void testAllFilesPresentInSyntax() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError/syntax"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("arrowReference.kt")
|
||||
public void testArrowReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/syntax/arrowReference.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("evaluationOrder.kt")
|
||||
public void testEvaluationOrder() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/syntax/evaluationOrder.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorectLexicalName.kt")
|
||||
public void testIncorectLexicalName() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("missedArgument.kt")
|
||||
public void testMissedArgument() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxError/syntax/missedArgument.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+37488
File diff suppressed because it is too large
Load Diff
Generated
+5181
File diff suppressed because it is too large
Load Diff
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.js.test.fir;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/boxWasmJsInterop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirJsES6CodegenWasmJsInteropTestGenerated extends AbstractFirJsES6CodegenWasmJsInteropTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInBoxWasmJsInterop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxWasmJsInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultValues.kt")
|
||||
public void testDefaultValues() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/defaultValues.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalTypeOperators.kt")
|
||||
public void testExternalTypeOperators() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externals.kt")
|
||||
public void testExternals() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/externals.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypes.kt")
|
||||
public void testFunctionTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/functionTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsCode.kt")
|
||||
public void testJsCode() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsCode.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsModule.kt")
|
||||
public void testJsModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsModule.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsModuleWithQualifier.kt")
|
||||
public void testJsModuleWithQualifier() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsModuleWithQualifier.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsQualifier.kt")
|
||||
public void testJsQualifier() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsQualifier.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jsToKotlinAdapters.kt")
|
||||
public void testJsToKotlinAdapters() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/jsToKotlinAdapters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kotlinToJsAdapters.kt")
|
||||
public void testKotlinToJsAdapters() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/kotlinToJsAdapters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("longStrings.kt")
|
||||
public void testLongStrings() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nameClash.kt")
|
||||
public void testNameClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/nameClash.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("types.kt")
|
||||
public void testTypes() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/types.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
runTest("compiler/testData/codegen/boxWasmJsInterop/vararg.kt");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// EXPECTED_REACHABLE_NODES: 1292
|
||||
package foo
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// EXPECTED_REACHABLE_NODES: 1270
|
||||
// SKIP_MINIFICATION
|
||||
// RUN_PLAIN_BOX_FUNCTION
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// EXPECTED_REACHABLE_NODES: 1323
|
||||
fun <T> checkThrown(x: T, block: (T) -> Any?): Unit? {
|
||||
return try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// FIR works fine, however it generates another names for the temporary variables, therefore ignore it
|
||||
|
||||
fun demo(f: () -> String) = f()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// TODO: Unmute when extension functions are supported in external declarations.
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND_K1: WASM
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// IGNORE_BACKEND_K1: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND_K1: JS_IR, JS_IR_ES6
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// TODO: Unmute when extension functions are supported in external declarations.
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND: WASM
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// IGNORE_BACKEND_K2: JS_IR
|
||||
// IGNORE_BACKEND_K2: JS_IR, JS_IR_ES6
|
||||
// EXPECTED_REACHABLE_NODES: 1314
|
||||
package foo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user