[JS] Fix typeOf for some reified type parameters

Fix getting kType metadata in cases when corresponding jsClass value
is passed through temporary variable.
This can happen when jsClass expression is not consided trivial by
local variable optimizer. This happens for object declarations from
different modules, for example kotlin.Unit
This commit is contained in:
Svyatoslav Kuzmich
2019-11-11 20:44:35 +03:00
parent c4d993d14c
commit 600fb723f4
4 changed files with 50 additions and 2 deletions
@@ -0,0 +1,22 @@
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
// TARGET_BACKEND: JS
// IGNORE_BACKEND: JS_IR
// WITH_REFLECT
import kotlin.reflect.typeOf
fun sideEffects() {
println("Side effect")
}
inline fun <reified T> foo(): String {
sideEffects()
val x = typeOf<T>().toString()
return x
}
fun box(): String {
if (foo<kotlin.Unit>() != "Unit")
return "FAIL"
return "OK"
}