c706673de9
- Merge `duplicatingItemsSameHashCode.kt` and
`duplicatingItemsSameHashCode2.kt` into one test enabled on both
backends, and rename it to
`duplicatingItemsSameHashCodeFewBranches.kt`.
- Rename `duplicatingItemsSameHashCode3.kt` to
`duplicatingItemsSameHashCodeMoreBranches.kt`, and also enable it for
both backends.
- Use JVM_TEMPLATES/JVM_IR_TEMPLATES to check backend-specific behavior:
1) JVM IR does not optimize less than 2 branches by design
2) JVM IR does not generate duplicate branches, also by design
Related to KT-36846.
20 lines
430 B
Kotlin
Vendored
20 lines
430 B
Kotlin
Vendored
fun foo(x : String) : String {
|
|
assert("abz]".hashCode() == "aby|".hashCode())
|
|
|
|
when (x) {
|
|
"abz]" -> return "abz"
|
|
"ghi" -> return "ghi"
|
|
"aby|" -> return "aby"
|
|
"abz]" -> return "fail"
|
|
}
|
|
|
|
return "other"
|
|
}
|
|
|
|
// JVM_TEMPLATES:
|
|
// 1 LOOKUPSWITCH
|
|
|
|
// JVM_IR_TEMPLATES:
|
|
// Expecting 0 LOOKUPSWITCH as there is only 2 different hash codes. An IF cascade is more efficient.
|
|
// 0 LOOKUPSWITCH
|