Skip to content

Commit 1c5dd2f

Browse files
andrey-mogilevSpace Team
authored andcommitted
[Wasm/Js] fix external instanceof in singleModule mode
^KT-81856 Fixed In singleModule compilation mode, no actual external_class_instanceof methods were exported from the module where the external class is declared, only the "adapters" for them. But the recent optimization uses the actual instanceof method instead of the adapters where possible, which leads to errors in singleModule mode.
1 parent f821d34 commit 1c5dd2f

File tree

9 files changed

+46
-3
lines changed

9 files changed

+46
-3
lines changed

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/JsInteropFunctionsLowering.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class JsInteropFunctionsLowering(val context: WasmBackendContext) : DeclarationT
120120
val jsFunction = context.irFactory.buildFun {
121121
origin = JS_CALL_INTEROP_FUNCTION
122122
name = function.name
123-
visibility = DescriptorVisibilities.PRIVATE
123+
visibility = DescriptorVisibilities.PUBLIC
124124
returnType = resultAdapter?.fromType ?: function.returnType
125125
modality = Modality.FINAL
126126
isExternal = true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// TARGET_BACKEND: WASM
2+
// MODULE: main
3+
4+
// FILE: test.kt
5+
6+
fun isJsString(obj: JsAny) : Boolean = obj is JsString
7+
8+
fun box(): String {
9+
if (!isJsString("foo".toJsString())) return "Fail for JsString"
10+
if (isJsString(1.toJsNumber())) return "Fail for JsNumber"
11+
12+
return "OK"
13+
}
14+
15+

compiler/testData/codegen/boxWasmJsInterop/genericReturnsExternal.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// TARGET_BACKEND: WASM
2-
// WASM_FAILS_IN_SINGLE_MODULE_MODE
32

43
external interface EI
54

compiler/testData/codegen/boxWasmJsInterop/jsTypes.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// TARGET_BACKEND: WASM
22
// WITH_STDLIB
3-
// WASM_FAILS_IN_SINGLE_MODULE_MODE
43

54
fun assertTrue(x: Boolean): Unit = check(x)
65
fun assertNull(x: Any?): Unit = check(x === null)

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/JsCodegenWasmJsInteropTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/JsCodegenWasmJsInteropWithInlinedFunInKlibTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/JsES6CodegenWasmJsInteropTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmJsCodegenInteropTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmJsCodegenSingleModuleInteropTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)