[NI] Correctly compute definitely not null type for intersection one

{ T : Any? & Foo & Bar? }!! -> { T!! & Foo & Bar }

 Also, fix bug with loosing non-representative number type.
 For example, for type { Byte & SomeType } we lost type `Byte` because
 `getDefaultPrimitiveNumberType` returns null for it

 Fixes #KT-28334 for NI
This commit is contained in:
Mikhail Zarechenskiy
2018-11-21 16:07:00 +03:00
parent aa224558bd
commit c6712ff861
8 changed files with 124 additions and 7 deletions
@@ -0,0 +1,38 @@
// !LANGUAGE: +NewInference
fun simpleTypeAndNumberType(b: Comparable<*>?) {
if (b is Byte?) {
<!DEBUG_INFO_SMARTCAST!>b<!>!!.dec()
}
}
fun <T> typeParmeterAndNumberType(b: T?) {
if (b is Byte?) {
b!!.dec()
}
}
fun anyAndNumberType(b: Any?) {
if (b is Byte?) {
<!DEBUG_INFO_SMARTCAST!>b<!>!!.dec()
}
}
fun comparableAndNumberType(b: Comparable<Byte>?) {
if (b is Byte?) {
<!DEBUG_INFO_SMARTCAST!>b<!>!!.dec()
}
}
object SeparateTypes {
interface A
interface B {
fun foo() {}
}
fun separate(a: A?) {
if (a is B?) {
a!!.foo()
}
}
}
@@ -0,0 +1,27 @@
package
public fun anyAndNumberType(/*0*/ b: kotlin.Any?): kotlin.Unit
public fun comparableAndNumberType(/*0*/ b: kotlin.Comparable<kotlin.Byte>?): kotlin.Unit
public fun simpleTypeAndNumberType(/*0*/ b: kotlin.Comparable<*>?): kotlin.Unit
public fun </*0*/ T> typeParmeterAndNumberType(/*0*/ b: T?): kotlin.Unit
public object SeparateTypes {
private constructor SeparateTypes()
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 final fun separate(/*0*/ a: SeparateTypes.A?): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public interface A {
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 B {
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
}
}