Files
kotlin-fork/compiler/testData/diagnostics/tests/when/DuplicatedLabels.fir.kt
T
Dmitriy Novozhilov e6b5cb5216 [TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
2020-12-16 19:52:25 +03:00

62 lines
1.2 KiB
Kotlin
Vendored

/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-313
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
* expressions, when-expression -> paragraph 9 -> sentence 1
* expressions, when-expression -> paragraph 2 -> sentence 4
* expressions, when-expression -> paragraph 2 -> sentence 5
*/
package test
const val four = 4
fun first(arg: Int) = when (arg) {
1 -> 2
2 -> 3
1 -> 4
4 -> 5
1 -> 6
2 -> 7
// Error should be here: see KT-11971
four -> 8
else -> 0
}
fun second(arg: String): Int {
when (arg) {
"ABC" -> return 0
"DEF" -> return 1
"ABC" -> return -1
"DEF" -> return -2
}
return 42
}
fun third(arg: Any?): Int {
when (arg) {
null -> return -1
is String -> return 0
is Double -> return 1
is Double -> return 2
null -> return 3
else -> return 5
}
}
enum class Color { RED, GREEN, BLUE }
fun fourth(arg: Color) = when (arg) {
Color.RED -> "RED"
Color.GREEN -> "GREEN"
Color.RED -> "BLUE"
Color.BLUE -> "BLUE"
}
fun fifth(arg: Any?) = when (arg) {
is Any -> "Any"
else -> ""
else -> null
}