Minor, add test on typeOf with intersection type

This commit is contained in:
Alexander Udalov
2021-07-08 22:58:54 +02:00
parent a7e48c3af1
commit d43ed1cf75
8 changed files with 61 additions and 0 deletions
@@ -0,0 +1,23 @@
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
// IGNORE_BACKEND: JS
// WITH_REFLECT
// KJS_WITH_FULL_RUNTIME
import kotlin.reflect.typeOf
class Inv<T>(val v: T)
interface X
interface Y
object A : X, Y
object B : X, Y
fun <T> sel(a: T, b: T) = a
inline fun <reified T> T.valueTypeOf() = typeOf<T>()
fun box(): String {
val t = sel(Inv(A), Inv(B)).v.valueTypeOf()
return if (t == typeOf<Any>()) "OK" else "Fail: $t"
}