[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,34 +1,34 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// KT-5068 Add special error for scala-like syntax 'fun foo(): Int = { 1 }'
fun test1(): Int = { return 1 }
fun test1(): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test3: () -> Int = fun (): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
fun outer() {
fun test1(): Int = { return 1 }
fun test1(): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test3: () -> Int = fun (): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
}
class Outer {
fun test1(): Int = { return 1 }
fun test1(): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test3: () -> Int = fun (): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1
class Nested {
fun test1(): Int = { return 1 }
fun test1(): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
fun test2(): Int = { 1 }
val test3: () -> Int = fun (): Int = { return 1 }
val test3: () -> Int = fun (): Int = { <!RETURN_NOT_ALLOWED!>return<!> 1 }
val test4: () -> Int = fun (): Int = { 1 }
fun test5(): Int { return { 1 } }
fun test6(): Int = fun (): Int = 1