Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/tryCatch/tryExpression.kt
T
Victor Petukhov 0857b9c9e7 Rethink constraints incorporation
Namely, remove incorporation “otherInsideMyConstraint” to eliminate
constraint system redundancy and produce a potentially very large number
 of constructs.
Instead, introduce not so “spreadable” incorporation during variable
fixation (equality constraint with result type into other constraints).
^KT-41644 Fixed
^KT-42195 Fixed
^KT-42920 Fixed
^KT-42791 Fixed
^KT-41741 Fixed
2020-11-25 11:15:20 +03:00

35 lines
725 B
Kotlin
Vendored

// !WITH_NEW_INFERENCE
// SKIP_TXT
class ExcA : Exception()
class ExcB(val map: Map<Int, Int>) : Exception()
fun test0(): List<Int> = run {
try {
emptyList()
} finally {
<!UNUSED_EXPRESSION!>""<!>
fun foo() {}
}
}
fun test1(): Map<Int, Int> = run {
try {
emptyMap()
} catch (e: ExcA) {
emptyMap()
} catch (e: ExcB) {
e.map
} finally {
<!UNUSED_EXPRESSION!>""<!>
}
}
fun test2(): Map<Int, Int> = run {
<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>try {
emptyMap()
} catch (e: ExcA) {
<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>mapOf(<!NI;TYPE_MISMATCH!>"" to ""<!>)<!>
}<!>
}