[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:
+6
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user