[NI] Fix reporting smartcast diagnostics for intersection types

#KT-30826 Fixed
This commit is contained in:
Dmitriy Novozhilov
2019-04-08 12:37:56 +03:00
parent 47b1ea7fa4
commit 033d7262a2
15 changed files with 115 additions and 36 deletions
@@ -31,8 +31,8 @@ fun test() {
x.foo().checkType { _<CharSequence?>() }
x.baz("")
x.baz(1).checkType { _<Unit>() }
<!OI;SMARTCAST_IMPOSSIBLE!>x<!>.baz(1, 2)
<!SMARTCAST_IMPOSSIBLE!>x<!>.baz(1, 2)
<!OI;SMARTCAST_IMPOSSIBLE!>x<!>.foobar().checkType { _<String>() }
<!SMARTCAST_IMPOSSIBLE!>x<!>.foobar().checkType { _<String>() }
}
}
@@ -0,0 +1,19 @@
// !WITH_NEW_INFERENCE
// Issue: KT-30826
interface I1
interface I2 {
fun foo() {}
}
class A : I1, I2
fun foo(x: I1?) {
var y = x
y as I2
val bar = {
<!SMARTCAST_IMPOSSIBLE!>y<!>.foo() // NPE in NI, smartcast impossible in OI
}
y = null
bar()
}
@@ -0,0 +1,24 @@
package
public fun foo(/*0*/ x: I1?): kotlin.Unit
public final class A : I1, I2 {
public constructor A()
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface I1 {
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 interface I2 {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}