[FE 1.0] Report DUPLICATE_LABEL_IN_WHEN on proper branches

^KT-50385 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-12-19 22:34:09 +03:00
committed by teamcity
parent d9a3dd09ea
commit eb753eac83
9 changed files with 185 additions and 7 deletions
+2 -2
View File
@@ -40,8 +40,8 @@ fun test() {
val s = "";
when (x) {
<!INCOMPATIBLE_TYPES!>s<!> -> 1
<!DUPLICATE_LABEL_IN_WHEN, INCOMPATIBLE_TYPES!>""<!> -> 1
<!DUPLICATE_LABEL_IN_WHEN, INCOMPATIBLE_TYPES!>s<!> -> 1
<!INCOMPATIBLE_TYPES!>""<!> -> 1
x -> 1
1 -> 1
}
@@ -0,0 +1,45 @@
// ISSUE: KT-50385
const val myF = false
const val myT = true
fun test_1(someBoolean: Boolean) {
val s = when (someBoolean) {
myT /* true */ -> 1
myF /* false */ -> 2
true -> 3
false -> 4
}
}
fun test_2(someBoolean: Boolean) {
val s = when (someBoolean) {
myT /* true */ -> 1
true -> 2
false -> 3
}
}
fun test_3(someBoolean: Boolean) {
val s = <!NO_ELSE_IN_WHEN!>when<!> (someBoolean) {
myT /* true */ -> 1
false -> 2
}
}
fun test_4(someBoolean: Boolean) {
val s = <!NO_ELSE_IN_WHEN!>when<!> (someBoolean) {
myT /* true */ -> 1
myT /* true */ -> 2
false -> 3
}
}
fun test_5(someBoolean: Boolean) {
val s = <!NO_ELSE_IN_WHEN!>when<!> (someBoolean) {
myT /* true */ -> 1
myT /* true */ -> 2
myT /* true */ -> 3
false -> 4
}
}
@@ -0,0 +1,46 @@
// ISSUE: KT-50385
const val myF = false
const val myT = true
fun test_1(someBoolean: Boolean) {
val s = when (someBoolean) {
<!DUPLICATE_LABEL_IN_WHEN!>myT<!> /* true */ -> 1
<!DUPLICATE_LABEL_IN_WHEN!>myF<!> /* false */ -> 2
true -> 3
false -> 4
}
}
fun test_2(someBoolean: Boolean) {
val s = when (someBoolean) {
<!DUPLICATE_LABEL_IN_WHEN!>myT<!> /* true */ -> 1
true -> 2
false -> 3
}
}
fun test_3(someBoolean: Boolean) {
val s = <!NO_ELSE_IN_WHEN!>when<!> (someBoolean) {
myT /* true */ -> 1
false -> 2
}
}
fun test_4(someBoolean: Boolean) {
val s = <!NO_ELSE_IN_WHEN!>when<!> (someBoolean) {
myT /* true */ -> 1
<!DUPLICATE_LABEL_IN_WHEN!>myT<!> /* true */ -> 2
false -> 3
}
}
fun test_5(someBoolean: Boolean) {
val s = <!NO_ELSE_IN_WHEN!>when<!> (someBoolean) {
myT /* true */ -> 1
<!DUPLICATE_LABEL_IN_WHEN!>myT<!> /* true */ -> 2
<!DUPLICATE_LABEL_IN_WHEN!>myT<!> /* true */ -> 3
false -> 4
}
}
@@ -0,0 +1,10 @@
package
public const val myF: kotlin.Boolean = false
public const val myT: kotlin.Boolean = true
public fun test_1(/*0*/ someBoolean: kotlin.Boolean): kotlin.Unit
public fun test_2(/*0*/ someBoolean: kotlin.Boolean): kotlin.Unit
public fun test_3(/*0*/ someBoolean: kotlin.Boolean): kotlin.Unit
public fun test_4(/*0*/ someBoolean: kotlin.Boolean): kotlin.Unit
public fun test_5(/*0*/ someBoolean: kotlin.Boolean): kotlin.Unit