No more reified types for catch parameter #KT-9742 Fixed
This commit is contained in:
@@ -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)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(): kotlin.String
|
||||
public inline fun </*0*/ reified E : java.lang.Exception, /*1*/ R> tryCatch(/*0*/ lazy: () -> R, /*1*/ failure: (E) -> R): R
|
||||
|
||||
public open class ZException</*0*/ T> : java.lang.Exception {
|
||||
public constructor ZException</*0*/ T>(/*0*/ p: T)
|
||||
public final override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public final override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final val p: T
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user