Files
kotlin-fork/compiler/testData/diagnostics/tests/when/When.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

61 lines
1.3 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-152
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 5
* expressions, when-expression -> paragraph 5 -> sentence 1
* expressions, when-expression -> paragraph 6 -> sentence 1
* expressions, when-expression -> paragraph 6 -> sentence 3
* expressions, when-expression -> paragraph 6 -> sentence 5
* expressions, when-expression -> paragraph 6 -> sentence 9
* expressions, when-expression -> paragraph 6 -> sentence 10
* expressions, when-expression -> paragraph 6 -> sentence 11
*/
fun Int.foo() : Boolean = true
fun foo() : Int {
val s = ""
val x = 1
when (x) {
is String -> 1
!is Int -> 1
is Any? -> 1
is Any -> 1
s -> 1
1 -> 1
1 <!AMBIGUITY!>+<!> <!UNRESOLVED_REFERENCE!>a<!> -> 1
in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1
!in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1
else -> 1
}
return 0
}
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
fun test() {
val x = 1;
val s = "";
when (x) {
s -> 1
"" -> 1
x -> 1
1 -> 1
}
val z = 1
when (z) {
else -> 1
1 -> 2
}
when (z) {
else -> 1
}
}