[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:
+38
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user