Function literal is now expression and function simultaneously for purposes of annotation target checking
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user