FE: introduce AllowEmptyIntersectionsInResultTypeResolver feature

Related to KT-51221
This commit is contained in:
Mikhail Glukhikh
2023-03-02 09:41:43 +01:00
committed by Space Team
parent fbea09b3b6
commit 47fab61716
10 changed files with 206 additions and 12 deletions
@@ -265,8 +265,9 @@ class ResultTypeResolver(
}
private fun Context.computeUpperType(upperConstraints: List<Constraint>): KotlinTypeMarker {
// TODO: Remove this after stopping support of K1
return if (!isK2) {
return if (languageVersionSettings.supportsFeature(LanguageFeature.AllowEmptyIntersectionsInResultTypeResolver)) {
intersectTypes(upperConstraints.map { it.type })
} else {
val intersectionUpperType = intersectTypes(upperConstraints.map { it.type })
val resultIsActuallyIntersection = intersectionUpperType.typeConstructor().isIntersection()
@@ -291,8 +292,6 @@ class ResultTypeResolver(
if (filteredUpperConstraints.isNotEmpty()) intersectTypes(filteredUpperConstraints) else intersectionUpperType
} else intersectionUpperType
upperType
} else {
intersectTypes(upperConstraints.map { it.type })
}
}