[FIR] Implement checker for exhaustive when's in expression position
This commit is contained in:
+29
-29
@@ -11,21 +11,21 @@ val mlist = MList()
|
||||
|
||||
fun work() {}
|
||||
|
||||
val xx1 = if (true) 42
|
||||
val xx2: Unit = if (true) 42
|
||||
val xx3 = idAny(if (true) 42)
|
||||
val xx4 = id(if (true) 42)
|
||||
val xx5 = idUnit(if (true) 42)
|
||||
val xx6 = null ?: if (true) 42
|
||||
val xx7 = "" + if (true) 42
|
||||
val xx1 = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
val xx2: Unit = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
val xx3 = idAny(<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42)
|
||||
val xx4 = id(<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42)
|
||||
val xx5 = idUnit(<!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42)
|
||||
val xx6 = null ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
val xx7 = "" + <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
|
||||
val wxx1 = when { true -> 42 }
|
||||
val wxx2: Unit = when { true -> 42 }
|
||||
val wxx3 = idAny(when { true -> 42 })
|
||||
val wxx4 = id(when { true -> 42 })
|
||||
val wxx5 = idUnit(when { true -> 42 })
|
||||
val wxx6 = null ?: when { true -> 42 }
|
||||
val wxx7 = "" + when { true -> 42 }
|
||||
val wxx1 = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
val wxx2: Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
val wxx3 = idAny(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
|
||||
val wxx4 = id(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
|
||||
val wxx5 = idUnit(<!NO_ELSE_IN_WHEN!>when<!> { true -> 42 })
|
||||
val wxx6 = null ?: <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
val wxx7 = "" + <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
|
||||
val fn1 = { if (true) 42 }
|
||||
val fn2 = { if (true) mlist.add() }
|
||||
@@ -41,24 +41,24 @@ val ufn4: () -> Unit = { when { true -> 42 } }
|
||||
val ufn5: () -> Unit = { when { true -> mlist.add() } }
|
||||
val ufn6: () -> Unit = { when { true -> work() } }
|
||||
|
||||
fun f1() = if (true) work()
|
||||
fun f2() = if (true) mlist.add()
|
||||
fun f3() = if (true) 42
|
||||
fun f4(): Unit = if (true) work()
|
||||
fun f5(): Unit = if (true) mlist.add()
|
||||
fun f6(): Unit = if (true) 42
|
||||
fun g1() = when { true -> work() }
|
||||
fun g2() = when { true -> mlist.add() }
|
||||
fun g3() = when { true -> 42 }
|
||||
fun g4(): Unit = when { true -> work() }
|
||||
fun g5(): Unit = when { true -> mlist.add() }
|
||||
fun g6(): Unit = when { true -> 42 }
|
||||
fun f1() = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) work()
|
||||
fun f2() = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) mlist.add()
|
||||
fun f3() = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
fun f4(): Unit = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) work()
|
||||
fun f5(): Unit = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) mlist.add()
|
||||
fun f6(): Unit = <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
fun g1() = <!NO_ELSE_IN_WHEN!>when<!> { true -> work() }
|
||||
fun g2() = <!NO_ELSE_IN_WHEN!>when<!> { true -> mlist.add() }
|
||||
fun g3() = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
fun g4(): Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> work() }
|
||||
fun g5(): Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> mlist.add() }
|
||||
fun g6(): Unit = <!NO_ELSE_IN_WHEN!>when<!> { true -> 42 }
|
||||
|
||||
fun foo1(x: String?) {
|
||||
"" + if (true) 42
|
||||
"" + <!INVALID_IF_AS_EXPRESSION!>if<!> (true) 42
|
||||
w@while (true) {
|
||||
x ?: if (true) break
|
||||
x ?: when { true -> break@w }
|
||||
x ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (true) break
|
||||
x ?: <!NO_ELSE_IN_WHEN!>when<!> { true -> break@w }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user