Support JvmName on annotation constructor parameters
#KT-25372 Fixed
This commit is contained in:
committed by
Ilya Gorbunov
parent
dc1f4c7d5b
commit
b55fc818d1
@@ -0,0 +1,29 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
annotation class Anno(@get:JvmName("uglyJvmName") val value: String)
|
||||
|
||||
@Anno(value = "OK")
|
||||
class Foo
|
||||
|
||||
|
||||
annotation class Meta(val anno: Anno)
|
||||
|
||||
@Meta(Anno(value = "OK"))
|
||||
fun bar() {}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val f = Foo::class.annotations.single()
|
||||
assertEquals("@Anno(uglyJvmName=OK)", f.toString())
|
||||
assertEquals("OK", (f as Anno).value)
|
||||
|
||||
val b = ::bar.annotations.single()
|
||||
assertEquals("@Meta(anno=@Anno(uglyJvmName=OK))", b.toString())
|
||||
assertEquals("OK", (b as Meta).anno.value)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -19,13 +19,22 @@ class A {
|
||||
@JvmName("OK") get
|
||||
}
|
||||
|
||||
annotation class Anno(@get:JvmName("uglyJvmName") val value: String)
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
import lib.*
|
||||
|
||||
@Anno("OK")
|
||||
fun annotated() {}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
v = 1
|
||||
consumeInt(v)
|
||||
|
||||
val annoValue = (::annotated.annotations.single() as Anno).value
|
||||
if (annoValue != "OK") return "Fail annotation value: $annoValue"
|
||||
|
||||
return A().OK
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user