No more reified types for catch parameter #KT-9742 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-11-27 18:23:47 +03:00
parent f0e467e474
commit c6be69a483
7 changed files with 63 additions and 5 deletions
@@ -0,0 +1,25 @@
// See KT-9816, KT-9742
// Not allowed in Java
open class ZException<T>(val p: T) : Exception()
fun foo(): String {
try {
throw ZException(11)
} catch (e: ZException<String>) {
return e.p
}
}
fun bar() {
try {
throw ZException(11)
} catch (e: ZException<*>) {}
}
inline fun <reified E : Exception, R> tryCatch(lazy: () -> R, failure: (E) -> R): R =
try {
lazy()
} catch (<!REIFIED_TYPE_IN_CATCH_CLAUSE!>e: E<!>) {
failure(e)
}