KT-22274 report error/warning on incorrect return target label
This commit is contained in:
+62
@@ -0,0 +1,62 @@
|
||||
// !LANGUAGE: +RestrictReturnStatementTarget
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Ann
|
||||
|
||||
fun testFunctionName() {
|
||||
return@testFunctionName
|
||||
}
|
||||
|
||||
fun testHighOrderFunctionName() {
|
||||
run {
|
||||
return@run
|
||||
}
|
||||
}
|
||||
|
||||
fun testLambdaLabel() =
|
||||
lambda@ {
|
||||
return@lambda
|
||||
}
|
||||
|
||||
fun testParenthesizedLambdaLabel() =
|
||||
lambda@ ( {
|
||||
return@lambda
|
||||
} )
|
||||
|
||||
fun testAnnotatedLambdaLabel() =
|
||||
lambda@ @Ann {
|
||||
return@lambda
|
||||
}
|
||||
|
||||
fun testLambdaMultipleLabels1() =
|
||||
lambda1@ lambda2@ {
|
||||
return@lambda1
|
||||
}
|
||||
|
||||
fun testLambdaMultipleLabels2() =
|
||||
lambda1@ lambda2@ {
|
||||
return@lambda2
|
||||
}
|
||||
|
||||
fun testAnonymousFunctionLabel() =
|
||||
anonFun@ fun() {
|
||||
return@anonFun
|
||||
}
|
||||
|
||||
fun testLoopLabelInReturn(xs: List<Int>) {
|
||||
L@ for (x in xs) {
|
||||
if (x > 0) <!NOT_A_FUNCTION_LABEL!>return@L<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun testValLabelInReturn() {
|
||||
L@ val fn = { <!NOT_A_FUNCTION_LABEL!>return@L<!> }
|
||||
fn()
|
||||
}
|
||||
|
||||
fun testHighOrderFunctionCallLabelInReturn() {
|
||||
L@ run {
|
||||
<!NOT_A_FUNCTION_LABEL!>return@L<!>
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun testAnnotatedLambdaLabel(): () -> kotlin.Unit
|
||||
public fun testAnonymousFunctionLabel(): () -> kotlin.Unit
|
||||
public fun testFunctionName(): kotlin.Unit
|
||||
public fun testHighOrderFunctionCallLabelInReturn(): kotlin.Unit
|
||||
public fun testHighOrderFunctionName(): kotlin.Unit
|
||||
public fun testLambdaLabel(): () -> kotlin.Unit
|
||||
public fun testLambdaMultipleLabels1(): () -> kotlin.Unit
|
||||
public fun testLambdaMultipleLabels2(): () -> kotlin.Unit
|
||||
public fun testLoopLabelInReturn(/*0*/ xs: kotlin.collections.List<kotlin.Int>): kotlin.Unit
|
||||
public fun testParenthesizedLambdaLabel(): () -> kotlin.Unit
|
||||
public fun testValLabelInReturn(): kotlin.Unit
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
// !LANGUAGE: -RestrictReturnStatementTarget
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Ann
|
||||
|
||||
fun testFunctionName() {
|
||||
return@testFunctionName
|
||||
}
|
||||
|
||||
fun testHighOrderFunctionName() {
|
||||
run {
|
||||
return@run
|
||||
}
|
||||
}
|
||||
|
||||
fun testLambdaLabel() =
|
||||
lambda@ {
|
||||
return@lambda
|
||||
}
|
||||
|
||||
fun testParenthesizedLambdaLabel() =
|
||||
lambda@ ( {
|
||||
return@lambda
|
||||
} )
|
||||
|
||||
fun testAnnotatedLambdaLabel() =
|
||||
lambda@ @Ann {
|
||||
return@lambda
|
||||
}
|
||||
|
||||
fun testLambdaMultipleLabels1() =
|
||||
lambda1@ lambda2@ {
|
||||
return@lambda1
|
||||
}
|
||||
|
||||
fun testLambdaMultipleLabels2() =
|
||||
lambda1@ lambda2@ {
|
||||
return@lambda2
|
||||
}
|
||||
|
||||
fun testAnonymousFunctionLabel() =
|
||||
anonFun@ fun() {
|
||||
return@anonFun
|
||||
}
|
||||
|
||||
fun testLoopLabelInReturn(xs: List<Int>) {
|
||||
L@ for (x in xs) {
|
||||
if (x > 0) <!NOT_A_FUNCTION_LABEL_WARNING!>return@L<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun testValLabelInReturn() {
|
||||
L@ val fn = { <!NOT_A_FUNCTION_LABEL_WARNING!>return@L<!> }
|
||||
fn()
|
||||
}
|
||||
|
||||
fun testHighOrderFunctionCallLabelInReturn() {
|
||||
L@ run {
|
||||
<!NOT_A_FUNCTION_LABEL_WARNING!>return@L<!>
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun testAnnotatedLambdaLabel(): () -> kotlin.Unit
|
||||
public fun testAnonymousFunctionLabel(): () -> kotlin.Unit
|
||||
public fun testFunctionName(): kotlin.Unit
|
||||
public fun testHighOrderFunctionCallLabelInReturn(): kotlin.Unit
|
||||
public fun testHighOrderFunctionName(): kotlin.Unit
|
||||
public fun testLambdaLabel(): () -> kotlin.Unit
|
||||
public fun testLambdaMultipleLabels1(): () -> kotlin.Unit
|
||||
public fun testLambdaMultipleLabels2(): () -> kotlin.Unit
|
||||
public fun testLoopLabelInReturn(/*0*/ xs: kotlin.collections.List<kotlin.Int>): kotlin.Unit
|
||||
public fun testParenthesizedLambdaLabel(): () -> kotlin.Unit
|
||||
public fun testValLabelInReturn(): kotlin.Unit
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Ann : kotlin.Annotation {
|
||||
public constructor Ann()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user