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:
+1
-1
@@ -11,5 +11,5 @@ fun test(bal: Array<Int>) {
|
||||
|
||||
val e: Unit = run { bar += 4 }
|
||||
|
||||
val f: Int = <!INITIALIZER_TYPE_MISMATCH!>run <!ARGUMENT_TYPE_MISMATCH!>{ bar += 4 }<!><!>
|
||||
val f: Int = run { <!ARGUMENT_TYPE_MISMATCH!>bar += 4<!> }
|
||||
}
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ fun testParameter() {
|
||||
takeFnToParameter(fun(): Unit { return Unit })
|
||||
takeFnToParameter(fun() { if (true) return })
|
||||
takeFnToParameter(fun() { if (true) return Unit })
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>takeFnToParameter<!>(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||
takeFnToParameter(fun() = <!UNRESOLVED_REFERENCE!>unresolved<!>())
|
||||
takeFnToParameter(fun() { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||
takeFnToParameter(fun(): Unit { <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||
takeFnToParameter(fun() { return <!UNRESOLVED_REFERENCE!>unresolved<!>() })
|
||||
|
||||
Vendored
+1
-1
@@ -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!>[]<!> }
|
||||
|
||||
Reference in New Issue
Block a user