[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
@@ -1,11 +0,0 @@
fun f() {
foo {
bar {
return@foo 1
}
return@foo 1
}
}
fun foo(a: Any) {}
fun bar(a: Any) {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
fun f() {
foo {
bar {
@@ -1,19 +0,0 @@
// !WITH_NEW_INFERENCE
fun test() {
run {return}
run {}
}
fun test2() {
run {return@test2}
run {}
}
fun test3() {
fun test4() {
run {return@test3}
run {}
}
}
fun <T> run(f: () -> T): T { return f() }
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !WITH_NEW_INFERENCE
fun test() {
run {<!RETURN_NOT_ALLOWED!>return<!>}
@@ -1,11 +0,0 @@
// !CHECK_TYPE
fun test2(a: Int) {
val x = run f@{
if (a > 0) return
return@f 1
}
checkSubtype<Int>(x)
}
fun <T> run(f: () -> T): T { return f() }
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
fun test2(a: Int) {