Function literal is now expression and function simultaneously for purposes of annotation target checking

This commit is contained in:
Mikhail Glukhikh
2015-09-21 16:20:36 +03:00
parent 997e9a7dd7
commit dd4601fd08
6 changed files with 44 additions and 5 deletions
@@ -0,0 +1,16 @@
@Target(AnnotationTarget.FUNCTION)
annotation class FunAnn
fun bar(arg: () -> Int) = arg()
@FunAnn fun gav() = 13
fun foo(arg: Int) {
// Literal is annotatable
bar @FunAnn { arg }
// Function expression too
val f = @FunAnn fun(): Int { return 42 }
// But here, f and gav should be annotated instead
bar(<!WRONG_ANNOTATION_TARGET!>@FunAnn<!> f)
bar(<!WRONG_ANNOTATION_TARGET!>@FunAnn<!> ::gav)
}