FIR checker: support DUPLICATE_LABEL_IN_WHEN

Changes from FE1.0:
1. As discussed previously, no expression evaluation happens during this
check.
2. FE1.0 doesn't check redundant object comparisons.
This commit is contained in:
Tianyu Geng
2021-06-23 13:31:40 -07:00
committed by Mikhail Glukhikh
parent 7c6326856b
commit 4915d8dda3
12 changed files with 109 additions and 17 deletions
@@ -41,6 +41,7 @@ fun third(arg: Any?): Int {
is Double -> return 1
is <!DUPLICATE_LABEL_IN_WHEN!>Double<!> -> return 2
<!DUPLICATE_LABEL_IN_WHEN!>null<!> -> return 3
!is String -> return 4
else -> return 5
}
}
@@ -59,3 +60,11 @@ fun fifth(arg: Any?) = when (arg) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>else -> null<!>
}
object Foo
fun sixth(arg: Any?) = when (arg) {
Foo -> ""
Foo -> ""
else -> null
}