Inline classes. Use inline class instead of underlying type

in annotations if underlying type is not nullable reference type.
Previously, it worked only for inline classes with primitive
underlying type and nullable reference type.

 #KT-44133
This commit is contained in:
Ilmir Usmanov
2021-09-20 23:25:18 +02:00
committed by Space
parent 80fbc262b3
commit e74e267d16
3 changed files with 45 additions and 15 deletions
@@ -1,17 +1,45 @@
// WITH_REFLECT
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
package test
import kotlin.reflect.KClass
inline class IC(val i: Int)
@JvmInline
value class ICInt(val i: Int)
@JvmInline
value class ICIntN(val i: Int?)
@JvmInline
value class ICAny(val a: Any)
annotation class Ann(val c: KClass<*>)
@Ann(IC::class)
class C
@Ann(ICInt::class)
class CInt
@Ann(ICIntN::class)
class CIntN
@Ann(ICAny::class)
class CAny
@Ann(Result::class)
class CResult
fun box(): String {
val klass = (C::class.annotations.first() as Ann).c.toString()
return if (klass == "class test.IC") "OK" else klass
var klass = (CInt::class.annotations.first() as Ann).c.toString()
if (klass != "class test.ICInt") return "Expected class test.ICInt, got $klass"
klass = (CIntN::class.annotations.first() as Ann).c.toString()
if (klass != "class test.ICIntN") return "Expected class test.ICIntN, got $klass"
klass = (CAny::class.annotations.first() as Ann).c.toString()
if (klass != "class test.ICAny") return "Expected class test.ICAny, got $klass"
klass = (CResult::class.annotations.first() as Ann).c.toString()
if (klass != "class kotlin.Result") return "Expected class kotlin.Result, got $klass"
return "OK"
}