[FIR] Remove implicit coercion of ifs and whens to Unit
The rule of thumb is the following: If the `if` and `when` can be successfully replaced with `while`, then it is used as a statement, otherwise, it is used as an expression. #KT-59883
This commit is contained in:
committed by
Space Team
parent
2e66954d01
commit
931f2eab58
+1
-1
@@ -18,7 +18,7 @@ fun testMixedIfAndWhen() =
|
||||
fun testWrappedExpressions() =
|
||||
if (true) {
|
||||
println()
|
||||
if (true) {
|
||||
<!INVALID_IF_AS_EXPRESSION!>if<!> (true) {
|
||||
println()
|
||||
if (true) {
|
||||
println()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package f
|
||||
|
||||
fun test(a: Boolean, b: Boolean): Int {
|
||||
return <!RETURN_TYPE_MISMATCH!>if(a) {
|
||||
return if(a) {
|
||||
1
|
||||
} else {
|
||||
if (b) {
|
||||
<!INVALID_IF_AS_EXPRESSION!>if<!> (b) {
|
||||
3
|
||||
}
|
||||
}<!>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user