FIR checker: COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT

FIR simply ignores anything after the first comma if the when expression
doesn't have a subject. Hence, the checker has to rely on PSI structure
instead.
This commit is contained in:
Tianyu Geng
2021-07-19 19:27:11 -07:00
committed by Ivan Kochurkin
parent db12a96e54
commit 1679da45ab
16 changed files with 113 additions and 25 deletions
@@ -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, o.length == 0 -> false
o == null<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> o.length == 0 -> false
else -> true
}
}
}
@@ -1,18 +0,0 @@
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-313
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
* expressions, when-expression -> paragraph 5 -> sentence 1
*/
fun foo(x: Int, y: Int): Int =
when {
x > 0, y > 0,<!SYNTAX!>,<!> x < 0 -> 1
else -> 0
}
fun bar(x: Int): Int =
when (x) {
0 -> 0
else -> 1
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*