Minor, add test on typeOf subtyping with mutable collections

This commit is contained in:
Alexander Udalov
2021-07-16 23:53:52 +02:00
parent 9ebd665c96
commit 3b513ba299
@@ -7,6 +7,8 @@ package test
import kotlin.reflect.KType
import kotlin.reflect.typeOf
import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.isSupertypeOf
import kotlin.test.assertEquals
fun check(expected: String, actual: KType) {
@@ -32,5 +34,10 @@ fun box(): String {
check("kotlin.collections.MutableMap<kotlin.Int, kotlin.Unit>", typeOf<MutableMap<Int, Unit>>())
check("kotlin.collections.MutableMap.MutableEntry<kotlin.Byte?, kotlin.collections.Set<*>>", typeOf<MutableMap.MutableEntry<Byte?, Set<*>>>())
check(typeOf<MutableList<Any>>().isSubtypeOf(typeOf<List<Any>>()))
check(!typeOf<List<Any>>().isSubtypeOf(typeOf<MutableList<Any>>()))
check(typeOf<List<Any>>().isSupertypeOf(typeOf<MutableList<Any>>()))
check(!typeOf<MutableList<Any>>().isSupertypeOf(typeOf<List<Any>>()))
return "OK"
}