From 1cf38415880813d027e9a76c8eb408984884d1ca Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Fri, 14 Jul 2023 14:15:15 +0200 Subject: [PATCH] [Wasm] Always use -0x30/sub when defining a struct type Otherwise, according to the spec, a type will be treated as a final, which is not correct in many cases. Later, we can generate final struct types when it's applicable. #KT-60200 Fixed --- .../jetbrains/kotlin/wasm/ir/convertors/WasmIrToBinary.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/convertors/WasmIrToBinary.kt b/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/convertors/WasmIrToBinary.kt index 3cd8df48c73..fa83b3754c5 100644 --- a/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/convertors/WasmIrToBinary.kt +++ b/wasm/wasm.ir/src/org/jetbrains/kotlin/wasm/ir/convertors/WasmIrToBinary.kt @@ -320,12 +320,16 @@ class WasmIrToBinary( } private fun appendStructTypeDeclaration(type: WasmStructDeclaration) { + b.writeVarInt7(-0x30) + val superType = type.superType if (superType != null) { - b.writeVarInt7(-0x30) appendVectorSize(1) appendModuleFieldReference(superType.owner) + } else { + appendVectorSize(0) } + b.writeVarInt7(-0x21) b.writeVarUInt32(type.fields.size) type.fields.forEach {