[JS IR BE] Support companion objects in external interfaces

These objects are referenced but value is not actually used.
Replace access to these references with null literals.
This commit is contained in:
Svyatoslav Kuzmich
2020-03-05 20:13:38 +03:00
committed by Zalim Bashorov
parent f4b94ccbc8
commit 3ec13d5bd6
4 changed files with 38 additions and 7 deletions
@@ -0,0 +1,17 @@
// EXPECTED_REACHABLE_NODES: 1303
// This hack is used in org.w3c.* part of standard library to represent unions of Strings
// Test that we are not actually trying to access nonexistent companion object
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
public external interface I {
companion object
}
public inline val I.Companion.O: I get() = "O".asDynamic().unsafeCast<I>()
public inline val I.Companion.K: I get() = "K".asDynamic().unsafeCast<I>()
fun box(): String {
if (I.O != I.O) return "Fail 1"
if (I.O == I.K) return "Fail 2"
return I.O.unsafeCast<String>() + I.K.unsafeCast<String>()
}