Exhaustive when on boolean argument. A set of tests.

Compile-time constants are taken into account. #KT-3743 Fixed.
This commit is contained in:
Mikhail Glukhikh
2015-05-12 16:27:05 +03:00
parent 633b252ff5
commit c4aa6d01a9
13 changed files with 138 additions and 17 deletions
@@ -0,0 +1,8 @@
// See also: KT-3743
fun foo(arg: Boolean): String {
// Must be exhaustive
return when(arg) {
true -> "truth"
false -> "falsehood"
}
}
@@ -0,0 +1,3 @@
package
internal fun foo(/*0*/ arg: kotlin.Boolean): kotlin.String
@@ -0,0 +1,7 @@
fun foo(arg: Boolean): String {
// Must be exhaustive
return when(arg) {
(true) -> "truth"
((false)) -> "falsehood"
}
}
@@ -0,0 +1,3 @@
package
internal fun foo(/*0*/ arg: kotlin.Boolean): kotlin.String
@@ -0,0 +1,8 @@
// See also: KT-3743
fun foo(arg: Boolean): String {
// Must be exhaustive
return when(arg) {
2 == 2 -> "truth"
2 == 1 -> "falsehood"
}
}
@@ -0,0 +1,3 @@
package
internal fun foo(/*0*/ arg: kotlin.Boolean): kotlin.String
@@ -0,0 +1,9 @@
// See also: KT-3743
fun foo(arg: Boolean?): String {
// Must be exhaustive
return when(arg) {
true -> "truth"
false -> "falsehood"
null -> "unknown"
}
}
@@ -0,0 +1,3 @@
package
internal fun foo(/*0*/ arg: kotlin.Boolean?): kotlin.String
@@ -0,0 +1,8 @@
// See also: KT-3743
fun foo(arg: Boolean?): String {
// Must be NOT exhaustive
return <!NO_ELSE_IN_WHEN!>when<!>(arg) {
true -> "truth"
false -> "falsehood"
}
}
@@ -0,0 +1,3 @@
package
internal fun foo(/*0*/ arg: kotlin.Boolean?): kotlin.String