Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/tryCatch/assignTry.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

112 lines
1.6 KiB
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// SKIP_TXT
class ExcA : Exception()
class ExcB : Exception()
fun test2() {
val s: String? = try {
""
}
catch (e: ExcA) {
null
}
catch (e: ExcB) <!TYPE_MISMATCH{NI}!>{
<!CONSTANT_EXPECTED_TYPE_MISMATCH{OI}!>10<!>
}<!>
s<!UNSAFE_CALL!>.<!>length
}
fun test3() {
val s: String? = try {
""
}
catch (e: ExcA) {
null
}
catch (e: ExcB) {
return
}
s<!UNSAFE_CALL!>.<!>length
}
fun test4() {
val s: String? = try {
""
}
catch (e: ExcA) {
null
}
finally {
<!UNUSED_EXPRESSION!>""<!>
}
s<!UNSAFE_CALL!>.<!>length
}
fun test5() {
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>s<!>: String? =<!> try {
""
}
catch (e: ExcA) {
null
}
finally {
return
}
<!UNREACHABLE_CODE!>s<!UNSAFE_CALL!>.<!>length<!>
}
fun test6() {
val s: String? = try {
""
}
catch (e: ExcA) {
return
}
catch (e: ExcB) {
return
}
s<!UNSAFE_CALL!>.<!>length
}
fun test7() {
val s: String? = try {
""
}
catch (e: ExcA) {
""
}
catch (e: ExcB) {
""
}
s<!UNSAFE_CALL!>.<!>length
}
fun test8() {
val s = try {
""
} catch (e: ExcA) {
null
}
s<!UNSAFE_CALL!>.<!>length
}
fun test9() {
val s = try {
""
} catch (e: ExcA) {
""
}
s.length
}
fun test10() {
val x = try {
""
} finally {
<!UNUSED_EXPRESSION!>42<!>
}
x.length
}