DFA: only stable values or qualified with stable receiver can be bound in x = y #KT-15792 Fixed

This commit is contained in:
Mikhail Glukhikh
2017-01-18 16:11:59 +03:00
committed by mglukhikh
parent 905e67e713
commit b7fb45f36e
6 changed files with 78 additions and 1 deletions
@@ -0,0 +1,45 @@
// KT-15792 and related
fun foo() {
var x: String? = ""
val y = x
x = null
if (y != null) {
<!DEBUG_INFO_CONSTANT!>x<!><!UNSAFE_CALL!>.<!>hashCode()
}
}
fun foo2() {
var x: String? = ""
val y = x
if (y != null) {
x<!UNSAFE_CALL!>.<!>hashCode()
}
}
fun bar(s: String?) {
var ss = s
val hashCode = ss?.hashCode()
ss = null
if (hashCode != null) {
<!DEBUG_INFO_CONSTANT!>ss<!><!UNSAFE_CALL!>.<!>hashCode()
}
}
fun bar2(s: String?) {
var ss = s
val hashCode = ss?.hashCode()
if (hashCode != null) {
ss<!UNSAFE_CALL!>.<!>hashCode()
}
}
class Some(var s: String?)
fun baz(arg: Some?) {
val ss = arg?.s
if (ss != null) {
<!DEBUG_INFO_SMARTCAST!>arg<!>.hashCode()
<!SMARTCAST_IMPOSSIBLE!><!DEBUG_INFO_SMARTCAST!>arg<!>.s<!>.hashCode()
}
}
@@ -0,0 +1,15 @@
package
public fun bar(/*0*/ s: kotlin.String?): kotlin.Unit
public fun bar2(/*0*/ s: kotlin.String?): kotlin.Unit
public fun baz(/*0*/ arg: Some?): kotlin.Unit
public fun foo(): kotlin.Unit
public fun foo2(): kotlin.Unit
public final class Some {
public constructor Some(/*0*/ s: kotlin.String?)
public final var s: 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
}