diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt index bcbfb912fb1..fb7f0837b60 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/ir2wasm/BodyGenerator.kt @@ -41,6 +41,11 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV error("Unexpected element of type ${element::class}") } + override fun visitTypeOperator(expression: IrTypeOperatorCall) { + require(expression.operator == IrTypeOperator.REINTERPRET_CAST) { "Other types of casts must be lowered" } + generateExpression(expression.argument) + } + override fun visitConst(expression: IrConst) { when (val kind = expression.kind) { is IrConstKind.Null -> generateDefaultInitializerForType(context.transformType(expression.type), body) @@ -129,10 +134,8 @@ class BodyGenerator(val context: WasmFunctionCodegenContext) : IrElementVisitorV override fun visitConstructorCall(expression: IrConstructorCall) { val klass: IrClass = expression.symbol.owner.parentAsClass - if (backendContext.inlineClassesUtils.isClassInlineLike(klass)) { - // Unboxed instance is just a constructor argument. - generateExpression(expression.getValueArgument(0)!!) - return + require(!backendContext.inlineClassesUtils.isClassInlineLike(klass)) { + "All inline class constructor calls must be lowered to static function calls" } val wasmGcType: WasmSymbol = context.referenceGcType(klass.symbol) diff --git a/compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt b/compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt index f3377beced7..f225a5e7f76 100644 --- a/compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt +++ b/compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt @@ -1,5 +1,3 @@ -// DONT_TARGET_EXACT_BACKEND: WASM -// WASM_MUTE_REASON: IGNORED_IN_JS inline class IC(val i: Int) { init { diff --git a/compiler/testData/codegen/box/inlineClasses/initBlock.kt b/compiler/testData/codegen/box/inlineClasses/initBlock.kt index 8980178f1c6..30fbf49077d 100644 --- a/compiler/testData/codegen/box/inlineClasses/initBlock.kt +++ b/compiler/testData/codegen/box/inlineClasses/initBlock.kt @@ -1,5 +1,3 @@ -// DONT_TARGET_EXACT_BACKEND: WASM -// WASM_MUTE_REASON: IGNORED_IN_JS inline class SingleInitBlock(val s: String) { init { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 2ecfbf626af..31cc5b72dd6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -6203,6 +6203,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt"); } + @TestMetadata("boxImplDoesNotExecuteInitBlock.kt") + public void testBoxImplDoesNotExecuteInitBlock() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxImplDoesNotExecuteInitBlock.kt"); + } + @TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); @@ -6428,6 +6433,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt"); } + @TestMetadata("initBlock.kt") + public void testInitBlock() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/initBlock.kt"); + } + @TestMetadata("inlineClassAsLastExpressionInInLambda.kt") public void testInlineClassAsLastExpressionInInLambda() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt");