Files
kotlin-fork/compiler/testData/codegen/box/jvmName/annotationProperties.kt
T
Alexander Udalov 5c807266f6 JVM IR: fix origin of file class in FileClassLowering
IrDeclarationOrigin.FILE_CLASS is used in CallableReferenceLowering to
generate correct declaration owner.

Many reflection tests start to fail with this commit because they are
now treating callable references to top level declarations as Kotlin
symbols and fail because there's no JVM signature for them; this is
fixed in subsequent commits (previously, they worked because without
Kotlin metadata, these files were treated as Java classes)
2019-02-07 21:23:02 +01:00

31 lines
676 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// WITH_REFLECT
package test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
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()
assertTrue("@test.Anno\\(uglyJvmName=\"?OK\"?\\)".toRegex().matches(f.toString()))
assertEquals("OK", (f as Anno).value)
val b = ::bar.annotations.single()
assertEquals("@test.Meta(anno=$f)", b.toString())
assertEquals("OK", (b as Meta).anno.value)
return "OK"
}