[Wasm] Fix unit issues
- Materialize unit when its value is actually needed. - Special-case Unit_getInstance return type at codegen. It should be a proper Unit object instead of a "void"
This commit is contained in:
committed by
TeamCityServer
parent
20ddaa9ebf
commit
b79719d6f5
+2
@@ -156,6 +156,8 @@ class InlineClassLowering(val context: CommonBackendContext) {
|
|||||||
+statement.transformStatement(object : IrElementTransformerVoid() {
|
+statement.transformStatement(object : IrElementTransformerVoid() {
|
||||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
|
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
|
||||||
expression.transformChildrenVoid()
|
expression.transformChildrenVoid()
|
||||||
|
// Static function for delegating constructors return unboxed instance of inline class
|
||||||
|
expression.type = irClass.defaultType
|
||||||
return irBlock(expression) {
|
return irBlock(expression) {
|
||||||
thisVar = createTmpVariable(
|
thisVar = createTmpVariable(
|
||||||
expression,
|
expression,
|
||||||
|
|||||||
+32
-19
@@ -7,13 +7,11 @@ package org.jetbrains.kotlin.ir.backend.js.lower
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
|
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.lower.AbstractValueUsageTransformer
|
import org.jetbrains.kotlin.backend.common.lower.AbstractValueUsageTransformer
|
||||||
|
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
||||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||||
import org.jetbrains.kotlin.ir.backend.js.utils.realOverrideTarget
|
import org.jetbrains.kotlin.ir.backend.js.utils.realOverrideTarget
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.isPrimitiveArray
|
import org.jetbrains.kotlin.ir.util.isPrimitiveArray
|
||||||
@@ -126,7 +124,7 @@ class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsag
|
|||||||
|
|
||||||
if (actualType.isUnit() && !expectedType.isUnit()) {
|
if (actualType.isUnit() && !expectedType.isUnit()) {
|
||||||
// Don't materialize Unit if value is known to be proper Unit on runtime
|
// Don't materialize Unit if value is known to be proper Unit on runtime
|
||||||
if (!this.isGetUnit()) {
|
if (!this.isGetUnit(irBuiltIns)) {
|
||||||
val unitValue = JsIrBuilder.buildGetObjectValue(actualType, context.irBuiltIns.unitClass)
|
val unitValue = JsIrBuilder.buildGetObjectValue(actualType, context.irBuiltIns.unitClass)
|
||||||
return JsIrBuilder.buildComposite(actualType, listOf(this, unitValue))
|
return JsIrBuilder.buildComposite(actualType, listOf(this, unitValue))
|
||||||
}
|
}
|
||||||
@@ -160,20 +158,6 @@ class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private tailrec fun IrExpression.isGetUnit(): Boolean =
|
|
||||||
when (this) {
|
|
||||||
is IrContainerExpression ->
|
|
||||||
when (val lastStmt = this.statements.lastOrNull()) {
|
|
||||||
is IrExpression -> lastStmt.isGetUnit()
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
|
|
||||||
is IrGetObjectValue ->
|
|
||||||
this.symbol == irBuiltIns.unitClass
|
|
||||||
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun buildSafeCall(
|
private fun buildSafeCall(
|
||||||
arg: IrExpression,
|
arg: IrExpression,
|
||||||
actualType: IrType,
|
actualType: IrType,
|
||||||
@@ -207,3 +191,32 @@ class AutoboxingTransformer(context: JsCommonBackendContext) : AbstractValueUsag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UnitMaterializationPass(val context: JsCommonBackendContext) : AbstractValueUsageTransformer(context.irBuiltIns), BodyLoweringPass {
|
||||||
|
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||||
|
irBody.transformChildrenVoid()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun IrExpression.useAsValue(value: IrValueDeclaration): IrExpression {
|
||||||
|
if (this.type == irBuiltIns.unitType && !this.isGetUnit(irBuiltIns)) {
|
||||||
|
val unitValue = JsIrBuilder.buildGetObjectValue(type, irBuiltIns.unitClass)
|
||||||
|
return JsIrBuilder.buildComposite(type, listOf(this, unitValue))
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private tailrec fun IrExpression.isGetUnit(irBuiltIns: IrBuiltIns): Boolean =
|
||||||
|
when (this) {
|
||||||
|
is IrContainerExpression ->
|
||||||
|
when (val lastStmt = this.statements.lastOrNull()) {
|
||||||
|
is IrExpression -> lastStmt.isGetUnit(irBuiltIns)
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
|
is IrGetObjectValue ->
|
||||||
|
this.symbol == irBuiltIns.unitClass
|
||||||
|
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.common.ir.isMethodOfAny
|
|||||||
import org.jetbrains.kotlin.backend.common.ir.isTopLevel
|
import org.jetbrains.kotlin.backend.common.ir.isTopLevel
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.backend.js.export.isExported
|
import org.jetbrains.kotlin.ir.backend.js.export.isExported
|
||||||
@@ -115,6 +116,9 @@ fun IrBody.prependFunctionCall(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun JsCommonBackendContext.findUnitGetInstanceFunction(): IrSimpleFunction =
|
||||||
|
mapping.objectToGetInstanceFunction[irBuiltIns.unitClass.owner]!!
|
||||||
|
|
||||||
fun IrDeclaration.isImportedFromModuleOnly(): Boolean {
|
fun IrDeclaration.isImportedFromModuleOnly(): Boolean {
|
||||||
return isTopLevel && isEffectivelyExternal() && (getJsModule() != null && !isJsNonModule() || (parent as? IrAnnotationContainer)?.getJsModule() != null)
|
return isTopLevel && isEffectivelyExternal() && (getJsModule() != null && !isJsNonModule() || (parent as? IrAnnotationContainer)?.getJsModule() != null)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,6 +328,12 @@ private val wasmNullSpecializationLowering = makeWasmModulePhase(
|
|||||||
description = "Specialize assigning Nothing? values to other types."
|
description = "Specialize assigning Nothing? values to other types."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val unitMaterializationPass = makeWasmModulePhase(
|
||||||
|
{ context -> UnitMaterializationPass(context) },
|
||||||
|
name = "UnitLoweringPass",
|
||||||
|
description = "Materialize unit instances"
|
||||||
|
)
|
||||||
|
|
||||||
private val staticMembersLoweringPhase = makeWasmModulePhase(
|
private val staticMembersLoweringPhase = makeWasmModulePhase(
|
||||||
::StaticMembersLowering,
|
::StaticMembersLowering,
|
||||||
name = "StaticMembersLowering",
|
name = "StaticMembersLowering",
|
||||||
@@ -499,5 +505,6 @@ val wasmPhases = NamedCompilerPhase(
|
|||||||
wasmThrowDebugLoweringPhase then
|
wasmThrowDebugLoweringPhase then
|
||||||
staticMembersLoweringPhase then
|
staticMembersLoweringPhase then
|
||||||
wasmNullSpecializationLowering then
|
wasmNullSpecializationLowering then
|
||||||
|
unitMaterializationPass then
|
||||||
validateIrAfterLowering
|
validateIrAfterLowering
|
||||||
)
|
)
|
||||||
|
|||||||
+58
-41
@@ -20,10 +20,7 @@ import org.jetbrains.kotlin.ir.backend.js.utils.realOverrideTarget
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.defaultType
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.util.getInlineClassBackingField
|
|
||||||
import org.jetbrains.kotlin.ir.util.isInterface
|
|
||||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
import org.jetbrains.kotlin.wasm.ir.*
|
import org.jetbrains.kotlin.wasm.ir.*
|
||||||
@@ -40,6 +37,13 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
|
|||||||
error("Unexpected element of type ${element::class}")
|
error("Unexpected element of type ${element::class}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val unitGetInstance by lazy { backendContext.mapping.objectToGetInstanceFunction[irBuiltIns.unitClass.owner]!! }
|
||||||
|
|
||||||
|
override fun visitGetObjectValue(expression: IrGetObjectValue) {
|
||||||
|
require(expression.symbol == irBuiltIns.unitClass)
|
||||||
|
body.buildCall(context.referenceFunction(unitGetInstance.symbol))
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitTypeOperator(expression: IrTypeOperatorCall) {
|
override fun visitTypeOperator(expression: IrTypeOperatorCall) {
|
||||||
require(expression.operator == IrTypeOperator.REINTERPRET_CAST) { "Other types of casts must be lowered" }
|
require(expression.operator == IrTypeOperator.REINTERPRET_CAST) { "Other types of casts must be lowered" }
|
||||||
generateExpression(expression.argument)
|
generateExpression(expression.argument)
|
||||||
@@ -329,11 +333,7 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
|
|||||||
statementToWasmInstruction(it)
|
statementToWasmInstruction(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expression.type != irBuiltIns.unitType) {
|
generateExpression(statements.last() as IrExpression)
|
||||||
generateExpression(statements.last() as IrExpression)
|
|
||||||
} else {
|
|
||||||
statementToWasmInstruction(statements.last())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitBreak(jump: IrBreak) {
|
override fun visitBreak(jump: IrBreak) {
|
||||||
@@ -345,18 +345,17 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitReturn(expression: IrReturn) {
|
override fun visitReturn(expression: IrReturn) {
|
||||||
generateExpression(expression.value)
|
if (
|
||||||
|
expression.value.type == irBuiltIns.unitType &&
|
||||||
// FIXME: Hack for "returning" Unit from functions with generic return type.
|
expression.returnTargetSymbol.owner.returnType(backendContext) == irBuiltIns.unitType
|
||||||
// Common case -- lambdas returning unit.
|
|
||||||
if (expression.value.type == irBuiltIns.unitType &&
|
|
||||||
expression.returnTargetSymbol.owner.returnType(backendContext) != irBuiltIns.unitType
|
|
||||||
) {
|
) {
|
||||||
val irReturnType = expression.returnTargetSymbol.owner.returnType(backendContext)
|
statementToWasmInstruction(expression.value)
|
||||||
|
} else {
|
||||||
|
generateExpression(expression.value)
|
||||||
|
}
|
||||||
|
|
||||||
if (irReturnType != irBuiltIns.unitType) {
|
if (context.irFunction is IrConstructor) {
|
||||||
generateDefaultInitializerForType(context.transformType(irReturnType), body)
|
body.buildGetLocal(context.referenceLocal(0))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle complex exported parameters.
|
// Handle complex exported parameters.
|
||||||
@@ -371,25 +370,6 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitWhen(expression: IrWhen) {
|
override fun visitWhen(expression: IrWhen) {
|
||||||
if (expression.type == irBuiltIns.unitType) {
|
|
||||||
var ifCount = 0
|
|
||||||
for (branch in expression.branches) {
|
|
||||||
if (!isElseBranch(branch)) {
|
|
||||||
generateExpression(branch.condition)
|
|
||||||
body.buildIf(label = null, resultType = null)
|
|
||||||
statementToWasmInstruction(branch.result)
|
|
||||||
body.buildElse()
|
|
||||||
ifCount++
|
|
||||||
} else {
|
|
||||||
statementToWasmInstruction(branch.result)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repeat(ifCount) { body.buildEnd() }
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val resultType = context.transformBlockResultType(expression.type)
|
val resultType = context.transformBlockResultType(expression.type)
|
||||||
var ifCount = 0
|
var ifCount = 0
|
||||||
for (branch in expression.branches) {
|
for (branch in expression.branches) {
|
||||||
@@ -489,10 +469,47 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
generateExpression(statement as IrExpression)
|
if (statement is IrContainerExpression) {
|
||||||
|
statement.statements.forEach { it ->
|
||||||
|
statementToWasmInstruction(it)
|
||||||
|
}
|
||||||
|
} else if (statement is IrWhen) {
|
||||||
|
var ifCount = 0
|
||||||
|
for (branch in statement.branches) {
|
||||||
|
if (!isElseBranch(branch)) {
|
||||||
|
generateExpression(branch.condition)
|
||||||
|
body.buildIf(label = null, resultType = null)
|
||||||
|
statementToWasmInstruction(branch.result)
|
||||||
|
body.buildElse()
|
||||||
|
ifCount++
|
||||||
|
} else {
|
||||||
|
statementToWasmInstruction(branch.result)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (statement.type != irBuiltIns.unitType && statement.type != irBuiltIns.nothingType) {
|
repeat(ifCount) { body.buildEnd() }
|
||||||
body.buildInstr(WasmOp.DROP)
|
} else {
|
||||||
|
generateExpression(statement as IrExpression)
|
||||||
|
|
||||||
|
var needDrop = true
|
||||||
|
if (statement.type == irBuiltIns.nothingType)
|
||||||
|
needDrop = false
|
||||||
|
|
||||||
|
if (statement is IrSetValue || statement is IrBreakContinue || statement is IrSetField || statement is IrLoop || statement is IrDelegatingConstructorCall) {
|
||||||
|
needDrop = false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statement is IrCall || statement is IrConstructorCall) {
|
||||||
|
val unitGetInstanceCall = statement is IrCall && statement.symbol.owner == unitGetInstance
|
||||||
|
if (statement.type == irBuiltIns.unitType && !unitGetInstanceCall) {
|
||||||
|
needDrop = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needDrop) {
|
||||||
|
body.buildInstr(WasmOp.DROP)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
|||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.ir.IrBuiltIns
|
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.utils.findUnitGetInstanceFunction
|
||||||
import org.jetbrains.kotlin.ir.backend.js.utils.realOverrideTarget
|
import org.jetbrains.kotlin.ir.backend.js.utils.realOverrideTarget
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||||
@@ -29,6 +30,8 @@ class DeclarationGenerator(val context: WasmModuleCodegenContext) : IrElementVis
|
|||||||
private val backendContext: WasmBackendContext = context.backendContext
|
private val backendContext: WasmBackendContext = context.backendContext
|
||||||
private val irBuiltIns: IrBuiltIns = backendContext.irBuiltIns
|
private val irBuiltIns: IrBuiltIns = backendContext.irBuiltIns
|
||||||
|
|
||||||
|
private val unitGetInstanceFunction: IrSimpleFunction by lazy { backendContext.findUnitGetInstanceFunction() }
|
||||||
|
|
||||||
override fun visitElement(element: IrElement) {
|
override fun visitElement(element: IrElement) {
|
||||||
error("Unexpected element of type ${element::class}")
|
error("Unexpected element of type ${element::class}")
|
||||||
}
|
}
|
||||||
@@ -84,8 +87,18 @@ class DeclarationGenerator(val context: WasmModuleCodegenContext) : IrElementVis
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
resultTypes = listOfNotNull(
|
resultTypes = listOfNotNull(
|
||||||
resultType.let {
|
run {
|
||||||
if (importedName != null && it is WasmRefNullType) WasmEqRef else it
|
val type = if (declaration == unitGetInstanceFunction) {
|
||||||
|
// Unit_getInstance returns true Unit reference instead of "void"
|
||||||
|
context.transformType(declaration.returnType)
|
||||||
|
} else {
|
||||||
|
resultType
|
||||||
|
}
|
||||||
|
|
||||||
|
if (importedName != null && type is WasmRefNullType)
|
||||||
|
WasmEqRef
|
||||||
|
else
|
||||||
|
type
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+21
-13
@@ -14,9 +14,12 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.irNot
|
import org.jetbrains.kotlin.backend.common.lower.irNot
|
||||||
import org.jetbrains.kotlin.backend.wasm.WasmBackendContext
|
import org.jetbrains.kotlin.backend.wasm.WasmBackendContext
|
||||||
import org.jetbrains.kotlin.backend.wasm.ir2wasm.erasedUpperBound
|
import org.jetbrains.kotlin.backend.wasm.ir2wasm.erasedUpperBound
|
||||||
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.utils.findUnitGetInstanceFunction
|
||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
|
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
|
||||||
@@ -35,6 +38,7 @@ class WasmTypeOperatorLowering(val context: WasmBackendContext) : FileLoweringPa
|
|||||||
class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrElementTransformerVoidWithContext() {
|
class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrElementTransformerVoidWithContext() {
|
||||||
private val symbols = context.wasmSymbols
|
private val symbols = context.wasmSymbols
|
||||||
private val builtIns = context.irBuiltIns
|
private val builtIns = context.irBuiltIns
|
||||||
|
private val unitGetInstance = context.findUnitGetInstanceFunction()
|
||||||
|
|
||||||
private lateinit var builder: DeclarationIrBuilder
|
private lateinit var builder: DeclarationIrBuilder
|
||||||
|
|
||||||
@@ -45,7 +49,7 @@ class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrEleme
|
|||||||
return when (expression.operator) {
|
return when (expression.operator) {
|
||||||
IrTypeOperator.IMPLICIT_CAST -> lowerImplicitCast(expression)
|
IrTypeOperator.IMPLICIT_CAST -> lowerImplicitCast(expression)
|
||||||
IrTypeOperator.IMPLICIT_DYNAMIC_CAST -> error("Dynamic casts are not supported in Wasm backend")
|
IrTypeOperator.IMPLICIT_DYNAMIC_CAST -> error("Dynamic casts are not supported in Wasm backend")
|
||||||
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> expression.argument
|
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> builder.irComposite(resultType = builtIns.unitType) { +expression.argument }
|
||||||
IrTypeOperator.IMPLICIT_INTEGER_COERCION -> lowerIntegerCoercion(expression)
|
IrTypeOperator.IMPLICIT_INTEGER_COERCION -> lowerIntegerCoercion(expression)
|
||||||
IrTypeOperator.IMPLICIT_NOTNULL -> lowerImplicitCast(expression)
|
IrTypeOperator.IMPLICIT_NOTNULL -> lowerImplicitCast(expression)
|
||||||
IrTypeOperator.INSTANCEOF -> lowerInstanceOf(expression, inverted = false)
|
IrTypeOperator.INSTANCEOF -> lowerInstanceOf(expression, inverted = false)
|
||||||
@@ -57,6 +61,19 @@ class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrEleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitVariable(declaration: IrVariable): IrStatement {
|
||||||
|
// Some IR passes, notable for-loops-lowering assumes implicit cast during variable initialization
|
||||||
|
val initializer = declaration.initializer
|
||||||
|
if (initializer != null &&
|
||||||
|
initializer.type != declaration.type
|
||||||
|
) {
|
||||||
|
builder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol).at(declaration)
|
||||||
|
declaration.initializer = narrowType(initializer.type, declaration.type, initializer)
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.visitVariable(declaration)
|
||||||
|
}
|
||||||
|
|
||||||
private fun lowerInstanceOf(
|
private fun lowerInstanceOf(
|
||||||
expression: IrTypeOperatorCall,
|
expression: IrTypeOperatorCall,
|
||||||
inverted: Boolean
|
inverted: Boolean
|
||||||
@@ -135,10 +152,7 @@ class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrEleme
|
|||||||
private fun generateTypeCheckNonNull(argument: IrExpression, toType: IrType): IrExpression {
|
private fun generateTypeCheckNonNull(argument: IrExpression, toType: IrType): IrExpression {
|
||||||
assert(!toType.isMarkedNullable())
|
assert(!toType.isMarkedNullable())
|
||||||
return when {
|
return when {
|
||||||
toType.isNothing() -> builder.irComposite(resultType = builtIns.booleanType) {
|
toType.isNothing() -> builder.irFalse()
|
||||||
+(argument)
|
|
||||||
+builder.irFalse()
|
|
||||||
}
|
|
||||||
toType.isTypeParameter() -> generateTypeCheckWithTypeParameter(argument, toType)
|
toType.isTypeParameter() -> generateTypeCheckWithTypeParameter(argument, toType)
|
||||||
toType.isInterface() -> generateIsInterface(argument, toType)
|
toType.isInterface() -> generateIsInterface(argument, toType)
|
||||||
else -> generateIsSubClass(argument, toType)
|
else -> generateIsSubClass(argument, toType)
|
||||||
@@ -281,16 +295,10 @@ class WasmBaseTypeOperatorTransformer(val context: WasmBackendContext) : IrEleme
|
|||||||
val fromTypeErased = fromType.erasedType
|
val fromTypeErased = fromType.erasedType
|
||||||
val toTypeErased = toType.erasedType
|
val toTypeErased = toType.erasedType
|
||||||
if (fromTypeErased.isSubtypeOfClass(toTypeErased.classOrNull!!)) {
|
if (fromTypeErased.isSubtypeOfClass(toTypeErased.classOrNull!!)) {
|
||||||
return builder.irComposite {
|
return builder.irTrue()
|
||||||
+argument
|
|
||||||
+builder.irTrue()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!toTypeErased.isSubtypeOfClass(fromTypeErased.classOrNull!!)) {
|
if (!toTypeErased.isSubtypeOfClass(fromTypeErased.classOrNull!!)) {
|
||||||
return builder.irComposite {
|
return builder.irFalse()
|
||||||
+argument
|
|
||||||
+builder.irFalse()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.irCall(symbols.refTest).apply {
|
return builder.irCall(symbols.refTest).apply {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
package array_test
|
package array_test
|
||||||
|
|
||||||
fun box() : String {
|
fun box() : String {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: INLINE_ARRAY_CONSTRUCTOR
|
||||||
typealias ArrayS = Array<String>
|
typealias ArrayS = Array<String>
|
||||||
|
|
||||||
fun testArray() {
|
fun testArray() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: EXCEPTIONS_NOT_IMPLEMENTED
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: EXCEPTIONS_NOT_IMPLEMENTED
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun println(s: String) {
|
fun println(s: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun println(s: String) {
|
fun println(s: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
|
|
||||||
fun bar(): Int? = foo() as? Int
|
fun bar(): Int? = foo() as? Int
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
class Bar {
|
class Bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
class ArrayWrapper<T>() {
|
class ArrayWrapper<T>() {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: COROUTINES
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// WITH_COROUTINES
|
// WITH_COROUTINES
|
||||||
import helpers.*
|
import helpers.*
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
var i = 0
|
var i = 0
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
data class A(val x: Unit)
|
data class A(val x: Unit)
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
data class A(val x: Unit)
|
data class A(val x: Unit)
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
Vendored
-2
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
// DONT_RUN_GENERATED_CODE: JS
|
// DONT_RUN_GENERATED_CODE: JS
|
||||||
|
|
||||||
tailrec fun foo(x: Int) {
|
tailrec fun foo(x: Int) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
interface A {
|
interface A {
|
||||||
val method : () -> Unit?
|
val method : () -> Unit?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
class A {
|
class A {
|
||||||
fun get(vararg x: Int) = x.size
|
fun get(vararg x: Int) = x.size
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-2
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
open class T(var value: Int) {}
|
open class T(var value: Int) {}
|
||||||
|
|
||||||
fun localExtensionOnNullableParameter(): T {
|
fun localExtensionOnNullableParameter(): T {
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
|
|
||||||
fun <T> myRun(action: () -> T): T = action()
|
fun <T> myRun(action: () -> T): T = action()
|
||||||
fun foo(): String = "foo"
|
fun foo(): String = "foo"
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
|
|
||||||
class Inv<T>(val x: T?)
|
class Inv<T>(val x: T?)
|
||||||
|
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
// !LANGUAGE: +InlineClasses
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
inline class UInt(private val value: Int) {
|
inline class UInt(private val value: Int) {
|
||||||
|
|||||||
-2
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun <T> tableView(init: Table<T>.() -> Unit) {
|
fun <T> tableView(init: Table<T>.() -> Unit) {
|
||||||
Table<T>().init()
|
Table<T>().init()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
// WASM_MUTE_REASON: STDLIB_COLLECTIONS
|
||||||
// KJS_WITH_FULL_RUNTIME
|
// KJS_WITH_FULL_RUNTIME
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
inline fun run2(block: () -> Unit) = block()
|
inline fun run2(block: () -> Unit) = block()
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
class A {
|
class A {
|
||||||
val prop: Int
|
val prop: Int
|
||||||
constructor(arg: Boolean) {
|
constructor(arg: Boolean) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
class A {
|
class A {
|
||||||
val prop: Int
|
val prop: Int
|
||||||
constructor(arg: Boolean) {
|
constructor(arg: Boolean) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun isNull(x: Unit?) = x == null
|
fun isNull(x: Unit?) = x == null
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
val c = Unit
|
val c = Unit
|
||||||
val d = c
|
val d = c
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun foo(): Any? = bar()
|
fun foo(): Any? = bar()
|
||||||
|
|
||||||
fun bar() {}
|
fun bar() {}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun <T : Any, R> T.let(f: (T) -> R): R = f(this)
|
fun <T : Any, R> T.let(f: (T) -> R): R = f(this)
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun isNull(x: Unit?) = x == null
|
fun isNull(x: Unit?) = x == null
|
||||||
|
|
||||||
fun <T : Any> isNullGeneric(x: T?) = x == null
|
fun <T : Any> isNullGeneric(x: T?) = x == null
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
Unit
|
Unit
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
|
||||||
// WASM_MUTE_REASON: UNIT_ISSUES
|
|
||||||
enum class En {
|
enum class En {
|
||||||
A,
|
A,
|
||||||
B
|
B
|
||||||
|
|||||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+140
@@ -458,6 +458,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
runTest("compiler/testData/codegen/box/arrays/kt4357.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt594.kt")
|
||||||
|
public void testKt594() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/arrays/kt594.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt7009.kt")
|
@TestMetadata("kt7009.kt")
|
||||||
public void testKt7009() throws Exception {
|
public void testKt7009() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/arrays/kt7009.kt");
|
runTest("compiler/testData/codegen/box/arrays/kt7009.kt");
|
||||||
@@ -1971,6 +1976,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/casts/objectToPrimitiveWithAssertion.kt");
|
runTest("compiler/testData/codegen/box/casts/objectToPrimitiveWithAssertion.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unitAsAny.kt")
|
||||||
|
public void testUnitAsAny() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/casts/unitAsAny.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unitAsSafeAny.kt")
|
||||||
|
public void testUnitAsSafeAny() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/casts/unitAsSafeAny.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unitNullableCast.kt")
|
||||||
|
public void testUnitNullableCast() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/casts/unitNullableCast.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/casts/functions")
|
@TestMetadata("compiler/testData/codegen/box/casts/functions")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
@@ -2284,6 +2304,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/classes/kt1891.kt");
|
runTest("compiler/testData/codegen/box/classes/kt1891.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt1918.kt")
|
||||||
|
public void testKt1918() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/kt1918.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt1976.kt")
|
@TestMetadata("kt1976.kt")
|
||||||
public void testKt1976() throws Exception {
|
public void testKt1976() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/classes/kt1976.kt");
|
runTest("compiler/testData/codegen/box/classes/kt1976.kt");
|
||||||
@@ -3436,6 +3461,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/controlStructures/kt2416.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/kt2416.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt2597.kt")
|
||||||
|
public void testKt2597() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/controlStructures/kt2597.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt299.kt")
|
@TestMetadata("kt299.kt")
|
||||||
public void testKt299() throws Exception {
|
public void testKt299() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/controlStructures/kt299.kt");
|
runTest("compiler/testData/codegen/box/controlStructures/kt299.kt");
|
||||||
@@ -3840,6 +3870,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/dataClasses/twoVarParams.kt");
|
runTest("compiler/testData/codegen/box/dataClasses/twoVarParams.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unitComponent.kt")
|
||||||
|
public void testUnitComponent() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/dataClasses/unitComponent.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/dataClasses/copy")
|
@TestMetadata("compiler/testData/codegen/box/dataClasses/copy")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
@@ -4035,6 +4070,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
public void testMixedParams() throws Exception {
|
public void testMixedParams() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/dataClasses/toString/mixedParams.kt");
|
runTest("compiler/testData/codegen/box/dataClasses/toString/mixedParams.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unitComponent.kt")
|
||||||
|
public void testUnitComponent() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/dataClasses/toString/unitComponent.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4780,6 +4820,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/sum.kt");
|
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/sum.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("tailCallInBlockInParentheses.kt")
|
||||||
|
public void testTailCallInBlockInParentheses() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/tailCallInBlockInParentheses.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("tailCallInParentheses.kt")
|
@TestMetadata("tailCallInParentheses.kt")
|
||||||
public void testTailCallInParentheses() throws Exception {
|
public void testTailCallInParentheses() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/tailCallInParentheses.kt");
|
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/tailCallInParentheses.kt");
|
||||||
@@ -5809,6 +5854,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/functions/kt1649_1.kt");
|
runTest("compiler/testData/codegen/box/functions/kt1649_1.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt1649_2.kt")
|
||||||
|
public void testKt1649_2() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/functions/kt1649_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt2270.kt")
|
@TestMetadata("kt2270.kt")
|
||||||
public void testKt2270() throws Exception {
|
public void testKt2270() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/functions/kt2270.kt");
|
runTest("compiler/testData/codegen/box/functions/kt2270.kt");
|
||||||
@@ -5844,6 +5894,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/functions/kt2929.kt");
|
runTest("compiler/testData/codegen/box/functions/kt2929.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt3214.kt")
|
||||||
|
public void testKt3214() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/functions/kt3214.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3313.kt")
|
@TestMetadata("kt3313.kt")
|
||||||
public void testKt3313() throws Exception {
|
public void testKt3313() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/functions/kt3313.kt");
|
runTest("compiler/testData/codegen/box/functions/kt3313.kt");
|
||||||
@@ -6155,6 +6210,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/functions/localFunctions/kt4989.kt");
|
runTest("compiler/testData/codegen/box/functions/localFunctions/kt4989.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("localExtensionOnNullableParameter.kt")
|
||||||
|
public void testLocalExtensionOnNullableParameter() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/functions/localFunctions/localExtensionOnNullableParameter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("localFunctionInConstructor.kt")
|
@TestMetadata("localFunctionInConstructor.kt")
|
||||||
public void testLocalFunctionInConstructor() throws Exception {
|
public void testLocalFunctionInConstructor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/functions/localFunctions/localFunctionInConstructor.kt");
|
runTest("compiler/testData/codegen/box/functions/localFunctions/localFunctionInConstructor.kt");
|
||||||
@@ -6578,6 +6638,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/inference/capturedTypesSubstitutionIntoAbbreviation.kt");
|
runTest("compiler/testData/codegen/box/inference/capturedTypesSubstitutionIntoAbbreviation.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("coercionToUnitWithLastLambdaExpression.kt")
|
||||||
|
public void testCoercionToUnitWithLastLambdaExpression() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/coercionToUnitWithLastLambdaExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("earlyReturnInsideCrossinlineLambda.kt")
|
@TestMetadata("earlyReturnInsideCrossinlineLambda.kt")
|
||||||
public void testEarlyReturnInsideCrossinlineLambda() throws Exception {
|
public void testEarlyReturnInsideCrossinlineLambda() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/earlyReturnInsideCrossinlineLambda.kt");
|
runTest("compiler/testData/codegen/box/inference/earlyReturnInsideCrossinlineLambda.kt");
|
||||||
@@ -6633,6 +6698,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt");
|
runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt")
|
||||||
|
public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
|
@TestMetadata("recursiveConstraintInsideTypeArgumentWithStarProjection.kt")
|
||||||
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
|
public void testRecursiveConstraintInsideTypeArgumentWithStarProjection() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
|
runTest("compiler/testData/codegen/box/inference/recursiveConstraintInsideTypeArgumentWithStarProjection.kt");
|
||||||
@@ -6792,6 +6862,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("boxUnboxOfInlineClassForCapturedVars.kt")
|
||||||
|
public void testBoxUnboxOfInlineClassForCapturedVars() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxOfInlineClassForCapturedVars.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("bridgeForFunctionReturningInlineClass.kt")
|
@TestMetadata("bridgeForFunctionReturningInlineClass.kt")
|
||||||
public void testBridgeForFunctionReturningInlineClass() throws Exception {
|
public void testBridgeForFunctionReturningInlineClass() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/bridgeForFunctionReturningInlineClass.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/bridgeForFunctionReturningInlineClass.kt");
|
||||||
@@ -9076,6 +9151,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/ir/hashCodeOnGenericSubstitutedWithPrimitive.kt");
|
runTest("compiler/testData/codegen/box/ir/hashCodeOnGenericSubstitutedWithPrimitive.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt25405.kt")
|
||||||
|
public void testKt25405() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ir/kt25405.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt40083.kt")
|
@TestMetadata("kt40083.kt")
|
||||||
public void testKt40083() throws Exception {
|
public void testKt40083() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
runTest("compiler/testData/codegen/box/ir/kt40083.kt");
|
||||||
@@ -14626,6 +14706,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/secondaryConstructors/varargs.kt");
|
runTest("compiler/testData/codegen/box/secondaryConstructors/varargs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("withNonLocalReturn.kt")
|
||||||
|
public void testWithNonLocalReturn() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/secondaryConstructors/withNonLocalReturn.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("withReturn.kt")
|
||||||
|
public void testWithReturn() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/secondaryConstructors/withReturn.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("withReturnUnit.kt")
|
||||||
|
public void testWithReturnUnit() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/secondaryConstructors/withReturnUnit.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("withoutPrimarySimple.kt")
|
@TestMetadata("withoutPrimarySimple.kt")
|
||||||
public void testWithoutPrimarySimple() throws Exception {
|
public void testWithoutPrimarySimple() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/secondaryConstructors/withoutPrimarySimple.kt");
|
runTest("compiler/testData/codegen/box/secondaryConstructors/withoutPrimarySimple.kt");
|
||||||
@@ -15955,11 +16050,36 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/unit"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/unit"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("closureReturnsNullableUnit.kt")
|
||||||
|
public void testClosureReturnsNullableUnit() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/closureReturnsNullableUnit.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ifElse.kt")
|
@TestMetadata("ifElse.kt")
|
||||||
public void testIfElse() throws Exception {
|
public void testIfElse() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/unit/ifElse.kt");
|
runTest("compiler/testData/codegen/box/unit/ifElse.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt3634.kt")
|
||||||
|
public void testKt3634() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/kt3634.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt4212.kt")
|
||||||
|
public void testKt4212() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/kt4212.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt4265.kt")
|
||||||
|
public void testKt4265() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/kt4265.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableUnit.kt")
|
||||||
|
public void testNullableUnit() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/nullableUnit.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nullableUnitInWhen1.kt")
|
@TestMetadata("nullableUnitInWhen1.kt")
|
||||||
public void testNullableUnitInWhen1() throws Exception {
|
public void testNullableUnitInWhen1() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen1.kt");
|
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen1.kt");
|
||||||
@@ -15969,6 +16089,21 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
public void testNullableUnitInWhen2() throws Exception {
|
public void testNullableUnitInWhen2() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen2.kt");
|
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableUnitInWhen3.kt")
|
||||||
|
public void testNullableUnitInWhen3() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/nullableUnitInWhen3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unitClassObject.kt")
|
||||||
|
public void testUnitClassObject() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/unitClassObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("UnitValue.kt")
|
||||||
|
public void testUnitValue() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/unit/UnitValue.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/unsignedTypes")
|
@TestMetadata("compiler/testData/codegen/box/unsignedTypes")
|
||||||
@@ -16330,6 +16465,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt");
|
runTest("compiler/testData/codegen/box/when/noElseExhaustiveStatement.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noElseExhaustiveUnitExpected.kt")
|
||||||
|
public void testNoElseExhaustiveUnitExpected() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/noElseExhaustiveUnitExpected.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noElseInStatement.kt")
|
@TestMetadata("noElseInStatement.kt")
|
||||||
public void testNoElseInStatement() throws Exception {
|
public void testNoElseInStatement() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/when/noElseInStatement.kt");
|
runTest("compiler/testData/codegen/box/when/noElseInStatement.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user