[K/Wasm] Allow to export unsigned numbers

This commit is contained in:
Artem Kobzar
2023-12-08 09:06:19 +00:00
committed by Space Team
parent a3c1f4ea12
commit 2eb1e65bbf
19 changed files with 528 additions and 24 deletions
@@ -26,7 +26,6 @@ object WasmJsPlatformConfigurator : PlatformConfiguratorBase(
JsExternalChecker, WasmExternalInheritanceChecker,
JsRuntimeAnnotationChecker,
JsExportAnnotationChecker,
JsExportDeclarationChecker,
WasmExternalDeclarationChecker,
WasmImportAnnotationChecker,
WasmJsFunAnnotationChecker,
@@ -51,6 +50,7 @@ object WasmJsPlatformConfigurator : PlatformConfiguratorBase(
container.useInstance(ExtensionFunctionToExternalIsInlinable)
container.useInstance(JsQualifierChecker)
container.useInstance(WasmDiagnosticSuppressor)
container.useInstance(JsExportDeclarationChecker(includeUnsignedNumbers = true))
}
override fun configureModuleDependentCheckers(container: StorageComponentContainer) {
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.isBoolean
import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType
import org.jetbrains.kotlin.types.typeUtil.isUnit
import org.jetbrains.kotlin.types.typeUtil.isUnsignedNumberType
object WasmImportAnnotationChecker : DeclarationChecker {
private val wasmImportFqName = FqName("kotlin.wasm.WasmImport")
@@ -54,7 +55,7 @@ object WasmImportAnnotationChecker : DeclarationChecker {
}
private fun isParameterTypeSupported(type: KotlinType): Boolean =
type.isPrimitiveNumberType() || type.isBoolean()
type.isPrimitiveNumberType() || type.isUnsignedNumberType() || type.isBoolean()
private fun isReturnTypeSupported(type: KotlinType): Boolean =
isParameterTypeSupported(type) || type.isUnit()
@@ -113,6 +113,7 @@ private fun isTypeSupportedInJsInterop(
val nonNullable = type.makeNotNullable()
if (
KotlinBuiltIns.isPrimitiveType(nonNullable) ||
KotlinBuiltIns.isUnsignedNumber(nonNullable) ||
KotlinBuiltIns.isString(nonNullable)
) {
return true
@@ -49,6 +49,12 @@ public class FirWasmCodegenWasmJsInteropTestGenerated extends AbstractFirWasmCod
runTest("compiler/testData/codegen/boxWasmJsInterop/externals.kt");
}
@Test
@TestMetadata("externalsWithUnsigned.kt")
public void testExternalsWithUnsigned() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/externalsWithUnsigned.kt");
}
@Test
@TestMetadata("functionTypes.kt")
public void testFunctionTypes() throws Exception {
@@ -49,6 +49,12 @@ public class K1WasmCodegenWasmJsInteropTestGenerated extends AbstractK1WasmCodeg
runTest("compiler/testData/codegen/boxWasmJsInterop/externals.kt");
}
@Test
@TestMetadata("externalsWithUnsigned.kt")
public void testExternalsWithUnsigned() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/externalsWithUnsigned.kt");
}
@Test
@TestMetadata("functionTypes.kt")
public void testFunctionTypes() throws Exception {