Minor, add test on typeOf subtyping with mutable collections
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user