Files
kotlin-fork/compiler/testData/diagnostics/tests/annotations/options/functions.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

41 lines
1.2 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
@Target(AnnotationTarget.FUNCTION)
annotation class FunAnn
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.SOURCE)
annotation class SourceAnn
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class ExprAnn
fun bar(arg: () -> Int) = arg()
inline fun fast(arg: () -> Int) = arg()
inline fun fast2(x: Int, arg: () -> Int) = x + arg()
@FunAnn fun gav() = 13
fun foo(arg: Int) {
// Literal is annotatable
bar @FunAnn { arg }
// Annotatable in principle but useless, fast is inline
fast <!NON_SOURCE_ANNOTATION_ON_INLINED_LAMBDA_EXPRESSION!>@FunAnn<!> { arg }
fast2(1, <!NON_SOURCE_ANNOTATION_ON_INLINED_LAMBDA_EXPRESSION!>@FunAnn<!> { arg })
// Source annotation, ok
fast @SourceAnn { arg }
fast2(1, @SourceAnn { arg })
// Expression annotation, ok
fast @ExprAnn { arg }
fast2(1, @ExprAnn { 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{OI}!>@<!DEBUG_INFO_MISSING_UNRESOLVED{NI}!>FunAnn<!><!> ::gav)
// Function expression, ok
fast(f)
}