[FE] Implement discussed rules to report empty intersection errors

This commit is contained in:
Victor Petukhov
2022-03-28 16:11:18 +03:00
committed by teamcity
parent b96708c3e2
commit 5bfe6cd20a
29 changed files with 241 additions and 62 deletions
@@ -178,26 +178,6 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
fun KotlinTypeMarker.isFinal(): Boolean
fun Collection<KotlinTypeMarker>.isEmptyIntersection(): Boolean {
val expandedTypes = buildSet {
for (type in this@isEmptyIntersection) {
val typeConstructor = type.typeConstructor()
when {
typeConstructor.isClassTypeConstructor() -> add(type)
typeConstructor.isTypeParameterTypeConstructor() -> addAll(typeConstructor.supertypes())
}
}
}.takeIf { it.isNotEmpty() } ?: return false
return expandedTypes.any { first ->
expandedTypes.any { second ->
first !== second &&
first.isFinal() &&
!AbstractTypeChecker.isSubtypeOf(this@TypeSystemInferenceExtensionContext, first, second)
}
}
}
fun KotlinTypeMarker.removeAnnotations(): KotlinTypeMarker
fun KotlinTypeMarker.removeExactAnnotation(): KotlinTypeMarker