Data flow values: initializers for local variables are now stored as "bound values" with inherited nullability #KT-6840 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-07-25 12:03:55 +03:00
parent 7090abddcd
commit 4f7d8e34b0
9 changed files with 74 additions and 26 deletions
@@ -5,8 +5,7 @@
fun kt6840_1(s: String?) {
val hash = s?.hashCode()
if (hash != null) {
// To be supported
s<!UNSAFE_CALL!>.<!>length
<!DEBUG_INFO_SMARTCAST!>s<!>.length
}
}
@@ -41,12 +40,11 @@ fun kt4565_1(a: SomeClass?) {
val data = a?.data
if (data != null) {
<!DEBUG_INFO_SMARTCAST!>data<!>.hashCode()
// To be supported
a<!UNSAFE_CALL!>.<!>hashCode()
a<!UNSAFE_CALL!>.<!>data.hashCode()
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode()
<!DEBUG_INFO_SMARTCAST!>a<!>.data.hashCode()
}
if (a?.data != null) {
// To be supported
// To be supported (?!)
data<!UNSAFE_CALL!>.<!>hashCode()
<!DEBUG_INFO_SMARTCAST!>a<!>.hashCode()
<!DEBUG_INFO_SMARTCAST!>a<!>.data.hashCode()
@@ -0,0 +1,20 @@
fun foo(arg: Int?) {
val x = arg
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>arg<!>.hashCode()
}
val y: Any? = arg
if (y != null) {
<!DEBUG_INFO_SMARTCAST!>arg<!>.hashCode()
}
val yy: Any?
yy = arg
if (yy != null) {
arg<!UNSAFE_CALL!>.<!>hashCode()
}
var z = arg
z = z?.let { 42 }
if (z != null) {
arg<!UNSAFE_CALL!>.<!>hashCode()
}
}
@@ -0,0 +1,3 @@
package
public fun foo(/*0*/ arg: kotlin.Int?): kotlin.Unit