Perform additional checks on catch parameter declaration
KT-8320 It should not be possible to catch a type parameter type KT-7645 Prohibit default value for `catch`-block parameter
This commit is contained in:
+3
-3
@@ -2,12 +2,12 @@
|
||||
|
||||
package foo
|
||||
|
||||
public fun <T : Throwable> failsWith(block: () -> Any): T {
|
||||
public inline fun <reified T : Throwable> failsWith(block: () -> Any): T {
|
||||
try {
|
||||
block()
|
||||
}
|
||||
catch (e: T) {
|
||||
return e
|
||||
catch (e: Throwable) {
|
||||
if (e is T) return e
|
||||
}
|
||||
|
||||
throw Exception("Should have failed")
|
||||
|
||||
Reference in New Issue
Block a user