Prohibit labeled returns inside kotlin.suspend argument lambdas

Probably, it would be more correct to skip such lambdas when resolving
the returns' references, but it'd be more complicated and still useless
since non-local returns are impossible in such lambdas
(relevant parameter is noinline)

 #KT-22900 Fixed
This commit is contained in:
Denis Zharkov
2018-02-19 14:14:09 +03:00
parent bc2e81a1e4
commit 5edfc0f5cd
8 changed files with 66 additions and 0 deletions
@@ -0,0 +1,27 @@
// SKIP_TXT
fun bar() {
suspend {
<!RETURN_FOR_BUILT_IN_SUSPEND!>return@suspend<!>
}
suspend {
run {
<!RETURN_FOR_BUILT_IN_SUSPEND!>return@suspend<!>
}
}
suspend l@{
return@l
}
suspend suspend@{
return@suspend
}
val <!UNUSED_VARIABLE!>x<!> = suspend@{
suspend {
// Might be resolved to outer lambda, but doesn't make sense because suspend-lambdas here is noinline
<!RETURN_FOR_BUILT_IN_SUSPEND!>return<!LABEL_NAME_CLASH!>@suspend<!><!>
}
}
}