Warn about comma-separated conditions in when without argument.

See KT-5143.
This commit is contained in:
Dmitry Petrov
2015-11-19 18:21:46 +03:00
parent b9e9c47b28
commit da90c21284
18 changed files with 215 additions and 19 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
public fun test(o: String?): Boolean {
return when {
// Data flow info should propagate from o == null to o.length
o == null, <!DEBUG_INFO_SMARTCAST!>o<!>.length == 0 -> false
o == null<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!DEBUG_INFO_SMARTCAST!>o<!>.length == 0 -> false
else -> true
}
}
@@ -0,0 +1,11 @@
fun foo(x: Int, y: Int): Int =
when {
x > 0<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> y > 0<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!><!SYNTAX!>,<!> x < 0 -> 1
else -> 0
}
fun bar(x: Int): Int =
when (x) {
0 -> 0
else -> 1
}
@@ -0,0 +1,4 @@
package
public fun bar(/*0*/ x: kotlin.Int): kotlin.Int
public fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Int