[FIR] Implement FirReturnAllowedChecker

Supported diagnostics:
- RETURN_NOT_ALLOWED
- RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY
This commit is contained in:
Dmitriy Novozhilov
2021-04-05 10:15:21 +03:00
committed by TeamCityServer
parent 254ff77977
commit 3cb17ac2f0
59 changed files with 263 additions and 343 deletions
@@ -12,11 +12,11 @@ fun test() {
doSmth(if (true) 3 else return, <!TOO_MANY_ARGUMENTS!>1<!>)
}
val a : Nothing = return 1
val a : Nothing = <!RETURN_NOT_ALLOWED!>return<!> 1
val b = return 1
val b = <!RETURN_NOT_ALLOWED!>return<!> 1
val c = doSmth(if (true) 3 else return)
val c = doSmth(if (true) 3 else <!RETURN_NOT_ALLOWED!>return<!>)
fun f(mi: Int = if (true) 0 else return) {}
@@ -10,11 +10,11 @@ fun f() = object : ClassData {
fun g() = object : ClassData {
init {
if (true) {
return 0
<!RETURN_NOT_ALLOWED!>return<!> 0
}
}
fun some(): Int {
return 6
}
}
}
@@ -31,7 +31,7 @@ fun testAnnotatedLambdaLabel() =
fun testLambdaMultipleLabels1() =
lambda1@ lambda2@ {
return@lambda1
<!RETURN_NOT_ALLOWED!>return@lambda1<!>
}
fun testLambdaMultipleLabels2() =
@@ -46,7 +46,7 @@ fun testAnonymousFunctionLabel() =
fun testLoopLabelInReturn(xs: List<Int>) {
L@ for (x in xs) {
if (x > 0) return@L
if (x > 0) <!RETURN_NOT_ALLOWED!>return@L<!>
}
}
@@ -59,4 +59,4 @@ fun testHighOrderFunctionCallLabelInReturn() {
L@ run {
return@L
}
}
}
@@ -31,7 +31,7 @@ fun testAnnotatedLambdaLabel() =
fun testLambdaMultipleLabels1() =
lambda1@ lambda2@ {
return@lambda1
<!RETURN_NOT_ALLOWED!>return@lambda1<!>
}
fun testLambdaMultipleLabels2() =
@@ -46,7 +46,7 @@ fun testAnonymousFunctionLabel() =
fun testLoopLabelInReturn(xs: List<Int>) {
L@ for (x in xs) {
if (x > 0) return@L
if (x > 0) <!RETURN_NOT_ALLOWED!>return@L<!>
}
}
@@ -59,4 +59,4 @@ fun testHighOrderFunctionCallLabelInReturn() {
L@ run {
return@L
}
}
}