Files
kotlin-fork/compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt
T
Mads Ager e5631addf3 [IR] Move annotations from original to new constructor declarations.
LocalDeclarationsLowering did not move annotations when creating
a new constructor declaration, thereby losing the annotations.

Fixes KT-45298
2021-03-05 12:24:38 -08:00

20 lines
484 B
Kotlin
Vendored

// WITH_REFLECT
// TARGET_BACKEND: JVM
// FILE: Ann.java
import java.lang.annotation.*;
@Target({ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann {}
// FILE: box.kt
fun box(): String {
class C(val x: String, val y: String) {
@Ann
constructor(v: String): this(v, v)
}
require(C::class.java.getDeclaredConstructor(String::class.java).getAnnotation(Ann::class.java) != null) { "no Ann on constructor" }
return "OK"
}