delegate use-site targeted annotations: parser, front-end, codegen with some tests #KT-10502 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-01-14 16:28:29 +03:00
parent 474076a550
commit b78d481bb1
29 changed files with 366 additions and 51 deletions
@@ -1,8 +1,14 @@
import kotlin.reflect.KProperty
@Retention(AnnotationRetention.SOURCE)
@Repeatable
annotation class RepeatableAnn
annotation class Ann
class CustomDelegate {
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name
}
public class A(@param:Ann <!REPEATED_ANNOTATION!>@Ann<!> val x: Int, @param: RepeatableAnn @Ann val y: Int) {
@field:Ann @property:Ann @RepeatableAnn @property:RepeatableAnn
@@ -17,4 +23,20 @@ public class A(@param:Ann <!REPEATED_ANNOTATION!>@Ann<!> val x: Int, @param: Rep
@property:RepeatableAnn @RepeatableAnn
val d: Int = 0
@property:RepeatableAnn @RepeatableAnn @delegate:RepeatableAnn
val e: String by CustomDelegate()
@property:Ann @delegate:Ann
val f: String by CustomDelegate()
// Ideally we should not have repeated anotation here and below
// (because @Ann should go to the property and the second annotation to its related field)
@Ann <!REPEATED_ANNOTATION!>@delegate:Ann<!>
val g: String by CustomDelegate()
@Ann <!REPEATED_ANNOTATION!>@field:Ann<!>
val h: String = ""
@property:Ann @field:Ann
val i: String = ""
}