IR: mostly remove descriptors from codegen
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// IGNORE_BACKEND: JS, JS_IR, NATIVE
|
||||
// IGNORE_BACKEND: JS, JS_IR, NATIVE, JVM_IR
|
||||
// WITH_REFLECT
|
||||
|
||||
package test
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_REFLECT
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.typeOf
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class C
|
||||
|
||||
fun check(expected: String, actual: KType) {
|
||||
assertEquals(expected, actual.toString())
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check("kotlin.Any", typeOf<Any>())
|
||||
check("kotlin.String", typeOf<String>())
|
||||
check("kotlin.String?", typeOf<String?>())
|
||||
check("kotlin.Unit", typeOf<Unit>())
|
||||
|
||||
check("test.C", typeOf<C>())
|
||||
check("test.C?", typeOf<C?>())
|
||||
|
||||
check("kotlin.collections.List<kotlin.String>", typeOf<List<String>>())
|
||||
check("kotlin.collections.Map<in kotlin.Number, *>?", typeOf<Map<in Number, *>?>())
|
||||
check("kotlin.Enum<*>", typeOf<Enum<*>>())
|
||||
check("kotlin.Enum<kotlin.annotation.AnnotationRetention>", typeOf<Enum<AnnotationRetention>>())
|
||||
|
||||
check("kotlin.Array<kotlin.Any>", typeOf<Array<Any>>())
|
||||
check("kotlin.Array<*>", typeOf<Array<*>>())
|
||||
check("kotlin.Array<kotlin.IntArray>", typeOf<Array<IntArray>>())
|
||||
check("kotlin.Array<in kotlin.Array<test.C>?>", typeOf<Array<in Array<C>?>>())
|
||||
|
||||
check("kotlin.Int", typeOf<Int>())
|
||||
check("kotlin.Int?", typeOf<Int?>())
|
||||
check("kotlin.Boolean", typeOf<Boolean>())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
package test
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// Separate test is needed for IR because type arguments of typeOf are computed differently.
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.typeOf
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class C
|
||||
|
||||
fun check(expected: String, actual: KType) {
|
||||
assertEquals(expected + " (Kotlin reflection is not available)", actual.toString())
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
check("java.lang.Object", typeOf<Any>())
|
||||
check("java.lang.String", typeOf<String>())
|
||||
check("java.lang.String?", typeOf<String?>())
|
||||
check("kotlin.Unit", typeOf<Unit>())
|
||||
|
||||
check("test.C", typeOf<C>())
|
||||
check("test.C?", typeOf<C?>())
|
||||
|
||||
check("java.util.List<java.lang.String>", typeOf<List<String>>())
|
||||
check("java.util.Map<in java.lang.Number, *>?", typeOf<Map<in Number, *>?>())
|
||||
check("java.lang.Enum<*>", typeOf<Enum<*>>())
|
||||
check("java.lang.Enum<kotlin.annotation.AnnotationRetention>", typeOf<Enum<AnnotationRetention>>())
|
||||
|
||||
check("kotlin.Array<java.lang.Object>", typeOf<Array<Any>>())
|
||||
check("kotlin.Array<*>", typeOf<Array<*>>())
|
||||
check("kotlin.Array<kotlin.IntArray>", typeOf<Array<IntArray>>())
|
||||
check("kotlin.Array<in kotlin.Array<test.C>?>", typeOf<Array<in Array<C>?>>())
|
||||
|
||||
check("int", typeOf<Int>())
|
||||
check("java.lang.Integer?", typeOf<Int?>())
|
||||
check("boolean", typeOf<Boolean>())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
package test
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.ExperimentalStdlibApi
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// Separate test is needed for IR because of different ways type arguments of typeOf are calculated.
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.typeOf
|
||||
|
||||
class C
|
||||
|
||||
fun assertEqual(a: KType, b: KType) {
|
||||
if (a != b || b != a) throw AssertionError("Fail equals: $a != $b")
|
||||
if (a.hashCode() != b.hashCode()) throw AssertionError("Fail hashCode: $a != $b")
|
||||
}
|
||||
|
||||
fun assertNotEqual(a: KType, b: KType) {
|
||||
if (a == b || b == a) throw AssertionError("Fail equals: $a == $b")
|
||||
}
|
||||
|
||||
inline fun <reified A, reified B> equal() {
|
||||
assertEqual(typeOf<A>(), typeOf<B>())
|
||||
}
|
||||
|
||||
inline fun <reified A, reified B> notEqual() {
|
||||
assertNotEqual(typeOf<A>(), typeOf<B>())
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
equal<Any, Any>()
|
||||
equal<Any?, Any?>()
|
||||
equal<String, String>()
|
||||
|
||||
equal<C, C>()
|
||||
equal<C?, C?>()
|
||||
|
||||
equal<List<String>, List<String>>()
|
||||
equal<Enum<AnnotationRetention>, Enum<AnnotationRetention>>()
|
||||
|
||||
equal<Array<Any>, Array<Any>>()
|
||||
equal<Array<IntArray>, Array<IntArray>>()
|
||||
equal<Array<*>, Array<*>>()
|
||||
|
||||
equal<Int, Int>()
|
||||
equal<Int?, Int?>()
|
||||
|
||||
notEqual<Any, Any?>()
|
||||
notEqual<Any, String>()
|
||||
notEqual<List<Any>, List<Any?>>()
|
||||
notEqual<Map<in Number, BooleanArray>, Map<out Number, BooleanArray>>()
|
||||
notEqual<Array<IntArray>, Array<Array<Int>>>()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user