Handling of try / catch / finally with 'Nothing' in all catch blocks #KT-10735 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-01-21 20:45:30 +03:00
parent 60f5d9ef8b
commit e9af4d25d0
4 changed files with 125 additions and 1 deletions
@@ -0,0 +1,80 @@
// See also KT-10735
fun test() {
var a: Int?
try {
a = 3
}
catch (e: Exception) {
return
}
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode() // a is never null here
}
class A: Exception()
class B: Exception()
fun test2() {
var a: Int?
try {
a = 4
}
catch (e: A) {
return
}
catch (e: B) {
return
}
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode() // a is never null here
}
fun test3() {
var a: Int? = null
try {
a = 5
}
catch (e: A) {
// do nothing
}
catch (e: B) {
return
}
a<!UNSAFE_CALL!>.<!>hashCode() // a is nullable here
}
fun test4() {
var a: Int? = null
try {
// do nothing
}
catch (e: A) {
return
}
catch (e: B) {
return
}
a<!UNSAFE_CALL!>.<!>hashCode() // a is nullable here
}
fun test5() {
var a: Int?// = null
try {
<!UNUSED_VALUE!>a =<!> 3
}
catch (e: Exception) {
return
}
finally {
// Error: KT-9825
<!UNUSED_VALUE!>a =<!> 5
}
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode() // a is never null here
}
fun test6() {
var a: Int?// = null
try {
<!UNUSED_VALUE!>a =<!> 3
}
catch (e: Exception) {
return
}
finally {
// Error: KT-9825
<!UNUSED_VALUE!>a =<!> null
}
<!DEBUG_INFO_CONSTANT!>a<!><!UNSAFE_CALL!>.<!>hashCode() // a is null here
}
@@ -0,0 +1,26 @@
package
public fun test(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun test3(): kotlin.Unit
public fun test4(): kotlin.Unit
public fun test5(): kotlin.Unit
public fun test6(): kotlin.Unit
public final class A : java.lang.Exception {
public constructor A()
public final override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public final override /*1*/ /*fake_override*/ val message: kotlin.String?
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B : java.lang.Exception {
public constructor B()
public final override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
public final override /*1*/ /*fake_override*/ val message: kotlin.String?
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}