[NI] Fix smartcasts computation for dot-qualifier expressions

This commit is contained in:
Mikhail Zarechenskiy
2018-04-16 17:43:07 +03:00
parent 55da251ffc
commit 3318549622
6 changed files with 35 additions and 3 deletions
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
class Item(val link: String?)
fun test(item: Item) {
if (item.link != null) {
val href: String = <!DEBUG_INFO_SMARTCAST!>item.link<!>
}
}
@@ -0,0 +1,11 @@
package
public fun test(/*0*/ item: Item): kotlin.Unit
public final class Item {
public constructor Item(/*0*/ link: kotlin.String?)
public final val link: 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
}
@@ -1,4 +1,3 @@
// !WITH_NEW_INFERENCE
// See also: KT-11998
data class My(val x: Boolean?)
@@ -7,7 +6,7 @@ fun doIt() {}
fun foo(my: My) {
if (my.x != null) {
// my.x should be smart-cast
if (<!DEBUG_INFO_SMARTCAST!>my.<!NI;TYPE_MISMATCH!>x<!><!>) doIt()
if (<!DEBUG_INFO_SMARTCAST!>my.x<!>) doIt()
when (<!DEBUG_INFO_SMARTCAST!>my.x<!>) {
true -> doIt()
}