Add test for class literals on inline classes
#KT-28361 Obsolete
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// WITH_REFLECT
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
package root
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
inline class IcInt(val x: Int)
|
||||
inline class IcLong(val l: Long)
|
||||
inline class IcAny(val a: Any?)
|
||||
inline class IcOverIc(val o: IcLong)
|
||||
|
||||
fun check(c: KClass<*>, s: String) {
|
||||
if (c.toString() != s) error("Fail, expected: $s, actual: $c")
|
||||
}
|
||||
|
||||
fun check(actual: String?, expected: String) {
|
||||
if (actual != expected) error("Fail, expected: $expected, actual: $actual")
|
||||
}
|
||||
|
||||
inline fun <reified T> reifiedCheck(asString: String, simpleName: String) {
|
||||
check(T::class, asString)
|
||||
check(T::class.simpleName, simpleName)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val i = IcInt(0)
|
||||
val l = IcLong(0)
|
||||
val a = IcAny("foo")
|
||||
val o = IcOverIc(IcLong(0))
|
||||
|
||||
check(i::class, "class root.IcInt")
|
||||
check(l::class, "class root.IcLong")
|
||||
check(a::class, "class root.IcAny")
|
||||
check(o::class, "class root.IcOverIc")
|
||||
check(1u::class, "class kotlin.UInt")
|
||||
|
||||
check(i::class.simpleName, "IcInt")
|
||||
check(l::class.simpleName, "IcLong")
|
||||
check(a::class.simpleName, "IcAny")
|
||||
check(o::class.simpleName, "IcOverIc")
|
||||
check(1u::class.simpleName, "UInt")
|
||||
|
||||
reifiedCheck<IcInt>("class root.IcInt", "IcInt")
|
||||
reifiedCheck<IcLong>("class root.IcLong", "IcLong")
|
||||
reifiedCheck<IcAny>("class root.IcAny", "IcAny")
|
||||
reifiedCheck<IcOverIc>("class root.IcOverIc", "IcOverIc")
|
||||
reifiedCheck<UInt>("class kotlin.UInt", "UInt")
|
||||
|
||||
val arrI = arrayOf(i)
|
||||
check(arrI[0]::class, "class root.IcInt")
|
||||
|
||||
val arrL = arrayOf(l)
|
||||
check(arrL[0]::class, "class root.IcLong")
|
||||
|
||||
val arrA = arrayOf(a)
|
||||
check(arrA[0]::class, "class root.IcAny")
|
||||
|
||||
val arrO = arrayOf(o)
|
||||
check(arrO[0]::class, "class root.IcOverIc")
|
||||
|
||||
val arrU = arrayOf(1u)
|
||||
check(arrU[0]::class, "class kotlin.UInt")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+10
@@ -13,6 +13,10 @@ fun check(c: Class<*>, s: String) {
|
||||
if (c.toString() != s) error("Fail, expected: $s, actual: $c")
|
||||
}
|
||||
|
||||
inline fun <reified T> reifiedCheck(asString: String) {
|
||||
check(T::class.java, asString)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val i = IcInt(0)
|
||||
val l = IcLong(0)
|
||||
@@ -31,6 +35,12 @@ fun box(): String {
|
||||
check(o::class.java, "class root.IcOverIc")
|
||||
check(1u::class.java, "class kotlin.UInt")
|
||||
|
||||
reifiedCheck<IcInt>("class root.IcInt")
|
||||
reifiedCheck<IcLong>("class root.IcLong")
|
||||
reifiedCheck<IcAny>("class root.IcAny")
|
||||
reifiedCheck<IcOverIc>("class root.IcOverIc")
|
||||
reifiedCheck<UInt>("class kotlin.UInt")
|
||||
|
||||
val arrI = arrayOf(i)
|
||||
check(arrI[0].javaClass, "class root.IcInt")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user