[FIR] Consider explicit returns during computing return type of anonymous function

Introduce FirAnonymousFunctionReturnExpressionInfo

^KT-59386
This commit is contained in:
Ivan Kochurkin
2023-07-12 21:56:39 +02:00
committed by Space Team
parent 212c10e674
commit 8f5294a508
8 changed files with 26 additions and 19 deletions
@@ -4,9 +4,9 @@ val a: () -> Int = <!INITIALIZER_TYPE_MISMATCH!>l@ {
if (flag) return@l 4
}<!>
val b: () -> Unit = l@ {
val b: () -> Unit = <!INITIALIZER_TYPE_MISMATCH!>l@ {
if (flag) return@l 4
}
}<!>
val c: () -> Any = l@ {
if (flag) return@l 4
@@ -10,13 +10,13 @@ val a: () -> Unit = l@{
if (true) 42
}
val b: () -> Unit = l@{
val b: () -> Unit = <!INITIALIZER_TYPE_MISMATCH!>l@{
// Error, coercion can't be applied at this position!
if (true) return@l "hello"
// However, this is OK, because here coercion is applied
"hello"
}
}<!>
val c: () -> Unit = {
// Interesting enough, for such expessions we use expected type Unit