Files
kotlin-fork/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.kt
T
Mikhail Zarechenskiy effdfe8ec0 Prohibit incorrect annotations with use-site targets more precisely
#KT-21696 Fixed

The problem is coming from the fact that `AnnotationTarget.VALUE_PARAMETER` is mapped to receiver parameter and to value parameter, but annotation with use-site target `receiver` can be used only on type reference of receiver parameter
2018-03-22 04:03:08 +03:00

25 lines
917 B
Kotlin
Vendored

annotation class Ann
<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET, WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@receiver:Ann<!>
class SomeClass {
<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET, WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@receiver:Ann<!>
constructor(<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@receiver:Ann<!> <!UNUSED_PARAMETER!>a<!>: String)
<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@receiver:Ann<!>
protected val simpleProperty: String = "text"
<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@receiver:Ann<!>
fun anotherFun() {
<!WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET!>@receiver:Ann<!>
val <!UNUSED_VARIABLE!>localVariable<!> = 5
}
val @receiver:Ann String.extensionProperty2: String
get() = "A"
}
fun @receiver:Ann String.length2() = length
val @receiver:Ann String.extensionProperty: String
get() = "A"