Files
kotlin-fork/compiler/testData/diagnostics/tests/smartCasts/castchecks/castInTryWithCatch.kt
T
Nikolay Lunyak 425d5e808b [FIR] Link some tests with issues
Just in case.

^KT-59874
2023-11-14 15:19:33 +00:00

35 lines
954 B
Kotlin
Vendored

// ISSUE: KT-56744
fun castInTry(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
} finally {
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
}
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
}
fun castInTryAndCatch(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s as String // Potential cast exception
} finally {
s.<!UNRESOLVED_REFERENCE!>length<!> // shouldn't be resolved
}
s.<!UNRESOLVED_REFERENCE!>length<!> // should be smartcast
}
fun castAtAll(s: Any) {
try {
s as String // Potential cast exception
} catch (e: Exception) {
s as String // Potential cast exception
} finally {
s as String // Potential cast exception
}
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}