FIR: assume a lambda returns Unit if it ends with a non-expression

While it is theoretically useful to know that `{ while(true) {} }`
returns Nothing, CFG node deadness is not precise enough to do that: if
the entire lambda is dead, it's no longer possible to find out whether
the loop is terminating. Besides, `while (true)` and `if (true)` are
pretty much the only constructs like that anyway.

Note that this commit does not affect resolution for lambdas that end in
a Nothing-returning expression, e.g. `throw`.
This commit is contained in:
pyos
2022-12-09 22:11:44 +01:00
committed by Dmitriy Novozhilov
parent 803abfeba8
commit 1eccb9aea1
12 changed files with 47 additions and 42 deletions
@@ -3,5 +3,5 @@
fun foo(l: () -> Unit) {}
fun bar(l: () -> String) {}
val a = foo { <!ARGUMENT_TYPE_MISMATCH, UNSUPPORTED!>[]<!> }
val a = foo { <!UNSUPPORTED!>[]<!> }
val b = bar { <!ARGUMENT_TYPE_MISMATCH, UNSUPPORTED!>[]<!> }