diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java index aaf68d3835f..6d50f14f77b 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/NativeInteropTest.java @@ -75,4 +75,8 @@ public final class NativeInteropTest extends SingleFileTranslationTest { public void testKt2209() throws Exception { fooBoxTest(); } + + public void testKt2388() throws Exception { + fooBoxTest(); + } } diff --git a/js/js.translator/testFiles/native/cases/Kt2388.kt b/js/js.translator/testFiles/native/cases/Kt2388.kt new file mode 100644 index 00000000000..1938b7044a5 --- /dev/null +++ b/js/js.translator/testFiles/native/cases/Kt2388.kt @@ -0,0 +1,20 @@ +package foo + +native +fun _setTimeout(callback:()->Unit):Unit = noImpl + +var done = false + +object foo { + var timeoutId: Long = 1 + + val callbackWrapper = { + timeoutId = -1 as Long + done = true + } +} + +fun box(): Boolean { + _setTimeout(foo.callbackWrapper) + return foo.timeoutId == -1 as Long +} diff --git a/js/js.translator/testFiles/native/native/Kt2388.js b/js/js.translator/testFiles/native/native/Kt2388.js new file mode 100644 index 00000000000..9593fd9db39 --- /dev/null +++ b/js/js.translator/testFiles/native/native/Kt2388.js @@ -0,0 +1,3 @@ +function _setTimeout(callback) { + callback.call({}); +}