Files
kotlin-fork/compiler/testData/diagnostics/tests/controlStructures/redundantLabel.kt
T
2021-10-27 12:26:59 +03:00

39 lines
845 B
Kotlin
Vendored

@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class Ann
fun testLambdaLabel() = l@ { 42 }
fun testAnonymousFunctionLabel() = l@ fun() {}
fun testAnnotatedLambdaLabel() = lambda@ @Ann {}
fun testParenthesizedLambdaLabel() = lambda@ ( {} )
fun testLabelBoundToInvokeOperatorExpression() = <!REDUNDANT_LABEL_WARNING!>l@<!> { 42 }()
fun testLabelBoundToLambda() = (l@ { 42 })()
fun testWhileLoopLabel() {
L@ while (true) {}
}
fun testDoWhileLoopLabel() {
L@ do {} while (true)
}
fun testForLoopLabel(xs: List<Any>) {
L@ for (x in xs) {}
}
fun testValLabel() {
<!REDUNDANT_LABEL_WARNING!>L@<!> val fn = {}
fn()
}
fun testHighOrderFunctionCallLabel() {
<!REDUNDANT_LABEL_WARNING!>L@<!> run {}
}
fun testAnonymousObjectLabel() =
<!REDUNDANT_LABEL_WARNING!>L@<!> object {}