[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
@@ -128,8 +128,12 @@ class ResultTypeResolver(
newSupertypes.add(supertype)
}
TypeUtils.getDefaultPrimitiveNumberType(numberSupertypes)?.let {
newSupertypes.add(it.unwrap())
val representativeNumberType = TypeUtils.getDefaultPrimitiveNumberType(numberSupertypes)
if (representativeNumberType != null) {
newSupertypes.add(representativeNumberType.unwrap())
} else {
newSupertypes.addAll(numberSupertypes.map { it.unwrap() })
}
intersectTypes(newSupertypes).makeNullableAsSpecified(commonSuperType.isMarkedNullable)