[FE] Support reporting INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION for empty intersection types with type parameters
This commit is contained in:
committed by
teamcity
parent
c16ae81a48
commit
b96708c3e2
@@ -178,15 +178,25 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
|
||||
fun KotlinTypeMarker.isFinal(): Boolean
|
||||
|
||||
fun Collection<KotlinTypeMarker>.isEmptyIntersection(): Boolean =
|
||||
any { first ->
|
||||
any { second ->
|
||||
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() &&
|
||||
second.typeConstructor().isClassTypeConstructor() &&
|
||||
!AbstractTypeChecker.isSubtypeOf(this@TypeSystemInferenceExtensionContext, first, second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun KotlinTypeMarker.removeAnnotations(): KotlinTypeMarker
|
||||
fun KotlinTypeMarker.removeExactAnnotation(): KotlinTypeMarker
|
||||
|
||||
Reference in New Issue
Block a user