ConeTypeIntersector: inline flatIntersectionTypes

This commit is contained in:
Mikhail Glukhikh
2022-12-27 22:48:30 +01:00
committed by Space Team
parent 45e884ec67
commit 8bc9fd91d5
@@ -17,8 +17,15 @@ object ConeTypeIntersector {
1 -> return types.single()
}
val inputTypes = mutableListOf<ConeKotlinType>()
flatIntersectionTypes(types, inputTypes)
val inputTypes = mutableListOf<ConeKotlinType>().apply {
for (inputType in types) {
if (inputType is ConeIntersectionType) {
addAll(inputType.intersectedTypes)
} else {
add(inputType)
}
}
}
/**
* resultNullability. Value description:
@@ -85,21 +92,6 @@ object ConeTypeIntersector {
}
}
private fun flatIntersectionTypes(
inputTypes: List<ConeKotlinType>,
typeCollector: MutableList<ConeKotlinType>
) {
for (inputType in inputTypes) {
if (inputType is ConeIntersectionType) {
for (type in inputType.intersectedTypes) {
typeCollector += type
}
} else {
typeCollector += inputType
}
}
}
private fun ConeKotlinType.isStrictSubtypeOf(context: ConeTypeContext, supertype: ConeKotlinType): Boolean =
AbstractTypeChecker.isSubtypeOf(context, this, supertype) && !AbstractTypeChecker.isSubtypeOf(context, supertype, this)