[FIR] Rename DUPLICATE_LABEL_IN_WHEN to DUPLICATE_BRANCH_CONDITION_IN_WHEN

... and fix the message

#KT-35289 Fixed
This commit is contained in:
Kirill Rakhman
2023-12-21 16:21:01 +01:00
committed by Space Team
parent 28eb78fe16
commit 8aa32d9f45
12 changed files with 117 additions and 28 deletions
@@ -15,10 +15,10 @@ const val four = 4
fun first(arg: Int) = when (arg) {
1 -> 2
2 -> 3
<!DUPLICATE_LABEL_IN_WHEN!>1<!> -> 4
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>1<!> -> 4
4 -> 5
<!DUPLICATE_LABEL_IN_WHEN!>1<!> -> 6
<!DUPLICATE_LABEL_IN_WHEN!>2<!> -> 7
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>1<!> -> 6
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>2<!> -> 7
// Error should be here: see KT-11971
four -> 8
else -> 0
@@ -28,8 +28,8 @@ fun second(arg: String): Int {
when (arg) {
"ABC" -> return 0
"DEF" -> return 1
<!DUPLICATE_LABEL_IN_WHEN!>"ABC"<!> -> return -1
<!DUPLICATE_LABEL_IN_WHEN!>"DEF"<!> -> return -2
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>"ABC"<!> -> return -1
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>"DEF"<!> -> return -2
}
return 42
}
@@ -39,8 +39,8 @@ fun third(arg: Any?): Int {
null -> return -1
is String -> return 0
is Double -> return 1
is <!DUPLICATE_LABEL_IN_WHEN!>Double<!> -> return 2
<!DUPLICATE_LABEL_IN_WHEN, SENSELESS_NULL_IN_WHEN!>null<!> -> return 3
is <!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>Double<!> -> return 2
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN, SENSELESS_NULL_IN_WHEN!>null<!> -> return 3
!is String -> return 4
else -> return 5
}
@@ -51,7 +51,7 @@ enum class Color { RED, GREEN, BLUE }
fun fourth(arg: Color) = when (arg) {
Color.RED -> "RED"
Color.GREEN -> "GREEN"
<!DUPLICATE_LABEL_IN_WHEN!>Color.RED<!> -> "BLUE"
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>Color.RED<!> -> "BLUE"
Color.BLUE -> "BLUE"
}
@@ -65,6 +65,6 @@ object Foo
fun sixth(arg: Any?) = when (arg) {
Foo -> ""
<!DUPLICATE_LABEL_IN_WHEN!>Foo<!> -> ""
<!DUPLICATE_BRANCH_CONDITION_IN_WHEN!>Foo<!> -> ""
else -> null
}
@@ -15,9 +15,9 @@ fun test(d: Any, dl: Collection<dynamic>) {
when (d) {
<!USELESS_IS_CHECK!>is <!DYNAMIC_NOT_ALLOWED!>dynamic<!><!> -> {}
<!USELESS_IS_CHECK!>is <!DUPLICATE_LABEL_IN_WHEN, DYNAMIC_NOT_ALLOWED!>dynamic?<!><!> -> {}
<!USELESS_IS_CHECK!>is <!DUPLICATE_BRANCH_CONDITION_IN_WHEN, DYNAMIC_NOT_ALLOWED!>dynamic?<!><!> -> {}
<!USELESS_IS_CHECK!>!is <!DYNAMIC_NOT_ALLOWED!>dynamic<!><!> -> {}
<!USELESS_IS_CHECK!>!is <!DUPLICATE_LABEL_IN_WHEN, DYNAMIC_NOT_ALLOWED!>dynamic?<!><!> -> {}
<!USELESS_IS_CHECK!>!is <!DUPLICATE_BRANCH_CONDITION_IN_WHEN, DYNAMIC_NOT_ALLOWED!>dynamic?<!><!> -> {}
}
dl as List<dynamic>