e0ebaac70c
KT-8320 It should not be possible to catch a type parameter type KT-7645 Prohibit default value for `catch`-block parameter
23 lines
437 B
Kotlin
Vendored
23 lines
437 B
Kotlin
Vendored
// KT-2470 another name mangling bug: kotlin.test.failsWith() gets generated to invalid JS
|
|
|
|
package foo
|
|
|
|
public inline fun <reified T : Throwable> failsWith(block: () -> Any): T {
|
|
try {
|
|
block()
|
|
}
|
|
catch (e: Throwable) {
|
|
if (e is T) return e
|
|
}
|
|
|
|
throw Exception("Should have failed")
|
|
}
|
|
|
|
fun box(): String {
|
|
val a = failsWith<Exception> {
|
|
throw Exception("OK")
|
|
}
|
|
|
|
return a.message!!
|
|
}
|