[NI] Consider intersection type with number type as Nothing

Currently, only for "in": In<in Int & A> == In<in Nothing> == In<*>

 #KT-37302 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-03-22 23:25:12 +03:00
parent b23aff4d0d
commit 191fb02bf6
26 changed files with 242 additions and 92 deletions
@@ -100,9 +100,9 @@ fun case_6() {
val x = select(Case6_1<Int>(), Case6_2<Float>(), null)
if (x != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("{InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<{Float & Int}> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<Nothing> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>} & {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<{Float & Int}> & Number}>>? & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<Nothing> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>?}")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("{InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<{Float & Int}> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<Nothing> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>} & {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<{Float & Int}> & Number}>>? & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<Nothing> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>?}")!>x<!>.ip1test1()
<!DEBUG_INFO_EXPRESSION_TYPE("{InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<{Float & Int}> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<Nothing> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>} & {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<{Float & Int}> & Number}>>? & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<Nothing> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>?}")!>x<!>.ip1test2()
<!DEBUG_INFO_EXPRESSION_TYPE("{InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>} & {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>>? & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>?}")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("{InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>} & {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>>? & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>?}")!>x<!>.ip1test1()
<!DEBUG_INFO_EXPRESSION_TYPE("{InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>} & {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>>? & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out InterfaceWithTypeParameter2<out {Comparable<*> & Number}>> & InterfaceWithTypeParameter2<out InterfaceWithTypeParameter2<out {InterfaceWithTypeParameter1<out Any?> & InterfaceWithTypeParameter2<out Any?>}>>}>>?}")!>x<!>.ip1test2()
}
}
@@ -114,8 +114,8 @@ fun case_7() {
val x = select(Case7_1<Int, Float>(), Case7_2<Char, String>(), null)
if (x != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("InterfaceWithTwoTypeParameters<out Inv<out {Comparable<{Int & String}> & java.io.Serializable}>, out Inv<out {Comparable<{Char & Float}> & java.io.Serializable}>> & InterfaceWithTwoTypeParameters<out Inv<out {Comparable<{Int & String}> & java.io.Serializable}>, out Inv<out {Comparable<{Char & Float}> & java.io.Serializable}>>?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("InterfaceWithTwoTypeParameters<out Inv<out {Comparable<{Int & String}> & java.io.Serializable}>, out Inv<out {Comparable<{Char & Float}> & java.io.Serializable}>> & InterfaceWithTwoTypeParameters<out Inv<out {Comparable<{Int & String}> & java.io.Serializable}>, out Inv<out {Comparable<{Char & Float}> & java.io.Serializable}>>?")!>x<!>.ip2test()
<!DEBUG_INFO_EXPRESSION_TYPE("InterfaceWithTwoTypeParameters<out Inv<out {Comparable<*> & java.io.Serializable}>, out Inv<out {Comparable<*> & java.io.Serializable}>> & InterfaceWithTwoTypeParameters<out Inv<out {Comparable<*> & java.io.Serializable}>, out Inv<out {Comparable<*> & java.io.Serializable}>>?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("InterfaceWithTwoTypeParameters<out Inv<out {Comparable<*> & java.io.Serializable}>, out Inv<out {Comparable<*> & java.io.Serializable}>> & InterfaceWithTwoTypeParameters<out Inv<out {Comparable<*> & java.io.Serializable}>, out Inv<out {Comparable<*> & java.io.Serializable}>>?")!>x<!>.ip2test()
}
}
@@ -127,24 +127,24 @@ fun case_8() {
val x = select(Case8_1<Int, Float>(), Case8_2<Char, String>(), null)
if (x != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>x<!>.test1()
val y = <!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>x<!>.test2()
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}>?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}>?")!>x<!>.test1()
val y = <!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters<out ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}>?")!>x<!>.test2()
if (y != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>y<!>.test1()
val z = <!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters<out {Comparable<{Int & String}> & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>y<!>.test2()
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>?")!>y<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>?")!>y<!>.test1()
val z = <!DEBUG_INFO_EXPRESSION_TYPE("ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters<out {Comparable<*> & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>?")!>y<!>.test2()
if (z != null) {
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z<!>
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z<!>.propT
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z<!>.propAny
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z<!>.propNullableT
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z<!>.propNullableAny
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z<!>.funT()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z<!>.funAny()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z<!>.funNullableT()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Int & String}> & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z<!>.funNullableAny()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.equals(null)
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.propT
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.propAny
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.propNullableT
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.propNullableAny
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.funT()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.funAny()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.funNullableT()
<!DEBUG_INFO_EXPRESSION_TYPE("{Comparable<*> & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z<!>.funNullableAny()
}
}
}