KT-1041 Add check that thrown/catched expression is of Throwable type
This commit is contained in:
@@ -162,7 +162,7 @@ fun illegalReturnIf(): Char {
|
||||
}
|
||||
|
||||
fun returnNothing(): Nothing {
|
||||
throw 1
|
||||
throw <!ERROR_COMPILE_TIME_VALUE!>1<!>
|
||||
}
|
||||
fun f(): Int {
|
||||
if (1 < 2) { return 1 } else returnNothing()
|
||||
|
||||
@@ -109,7 +109,7 @@ fun t7() : Int {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
catch (e : Any) {
|
||||
catch (<!TYPE_MISMATCH!>e : Any<!>) {
|
||||
<!UNUSED_EXPRESSION!>2<!>
|
||||
}
|
||||
return 1 // this is OK, like in Java
|
||||
@@ -120,7 +120,7 @@ fun t8() : Int {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
catch (e : Any) {
|
||||
catch (<!TYPE_MISMATCH!>e : Any<!>) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class Throwables() {
|
||||
public fun propagateIfInstanceOf<X : Throwable?>(throwable : Throwable?, declaredType : Class<X?>?) {
|
||||
if (((throwable != null) && declaredType?.isInstance(throwable).sure()))
|
||||
{
|
||||
throw declaredType?.cast(throwable)
|
||||
throw declaredType?.cast(throwable).sure()
|
||||
}
|
||||
}
|
||||
public fun propagateIfPossible(throwable : Throwable?) {
|
||||
|
||||
Reference in New Issue
Block a user