Extract EmptyIntersectionTypeKind.isDefinitelyEmpty to a property

This commit is contained in:
Mikhail Glukhikh
2022-12-05 10:58:04 +01:00
committed by Space Team
parent 4d01ad439a
commit 29ad5f981c
6 changed files with 18 additions and 30 deletions
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.EmptyIntersectionTypeKind
import org.jetbrains.kotlin.types.isDefinitelyEmpty
import org.jetbrains.kotlin.types.isPossiblyEmpty
import org.jetbrains.kotlin.types.TypeCheckerState
import org.jetbrains.kotlin.types.model.*
@@ -41,11 +39,13 @@ internal object EmptyIntersectionTypeChecker {
val typeInfo = computeByHavingCommonSubtype(firstSubstitutedType, secondSubstitutedType) ?: continue
if (typeInfo.kind.isDefinitelyEmpty())
if (typeInfo.kind.isDefinitelyEmpty) {
return typeInfo
}
if (typeInfo.kind.isPossiblyEmpty())
if (!typeInfo.kind.isDefinitelyEmpty) {
possibleEmptyIntersectionTypeInfo = typeInfo
}
}
}
@@ -5,16 +5,8 @@
package org.jetbrains.kotlin.types
enum class EmptyIntersectionTypeKind(val description: String) {
MULTIPLE_CLASSES("multiple incompatible classes"),
INCOMPATIBLE_SUPERTYPES("incompatible supertypes"),
INCOMPATIBLE_TYPE_ARGUMENTS("incompatible type arguments"),
FINAL_CLASS_AND_INTERFACE("final class and interface")
enum class EmptyIntersectionTypeKind(val description: String, val isDefinitelyEmpty: Boolean) {
MULTIPLE_CLASSES("multiple incompatible classes", isDefinitelyEmpty = true),
INCOMPATIBLE_SUPERTYPES("incompatible supertypes", isDefinitelyEmpty = true),
FINAL_CLASS_AND_INTERFACE("final class and interface", isDefinitelyEmpty = false)
}
fun EmptyIntersectionTypeKind.isDefinitelyEmpty(): Boolean =
this == EmptyIntersectionTypeKind.MULTIPLE_CLASSES
|| this == EmptyIntersectionTypeKind.INCOMPATIBLE_SUPERTYPES
|| this == EmptyIntersectionTypeKind.INCOMPATIBLE_TYPE_ARGUMENTS
fun EmptyIntersectionTypeKind.isPossiblyEmpty(): Boolean = this == EmptyIntersectionTypeKind.FINAL_CLASS_AND_INTERFACE