[K/JS] Add ability to use is checks on external objects

This commit is contained in:
Artem Kobzar
2023-03-10 11:33:30 +00:00
committed by Space Team
parent e5523c196e
commit ab7b429298
9 changed files with 64 additions and 0 deletions
@@ -3824,6 +3824,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
public void testSimpleIsInterface() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsInterface.kt");
}
@Test
@TestMetadata("simpleIsObject.kt")
public void testSimpleIsObject() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsObject.kt");
}
}
@Nested
@@ -4440,6 +4440,12 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
public void testSimpleIsInterface() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsInterface.kt");
}
@Test
@TestMetadata("simpleIsObject.kt")
public void testSimpleIsObject() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsObject.kt");
}
}
@Nested
@@ -4546,6 +4546,12 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
public void testSimpleIsInterface() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsInterface.kt");
}
@Test
@TestMetadata("simpleIsObject.kt")
public void testSimpleIsObject() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsObject.kt");
}
}
@Nested
@@ -4440,6 +4440,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
public void testSimpleIsInterface() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsInterface.kt");
}
@Test
@TestMetadata("simpleIsObject.kt")
public void testSimpleIsObject() throws Exception {
runTest("js/js.translator/testData/box/expression/typeCheck/simpleIsObject.kt");
}
}
@Nested
@@ -0,0 +1,22 @@
// EXPECTED_REACHABLE_NODES: 1403
// IGNORE_BACKEND: JS
package foo
object RegularKotlinObject
@JsName("Array")
external object JsArray
@JsName("Math")
external object JsMath
fun box(): String {
if (js("[]") !is JsArray) return "fail1"
if (js("[]") is JsMath) return "fail2"
if (js("[]") is RegularKotlinObject) return "fail3"
if (JsMath !is JsMath) return "fail4"
if (RegularKotlinObject !is RegularKotlinObject) return "fail5"
return "OK"
}