From d694c5d219e7fb1210acd2ec95be8dd4e87d9b99 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Fri, 20 Oct 2023 18:02:09 +0300 Subject: [PATCH] [FIR] Add references to the related K1 functions --- .../FirEqualityCompatibilityChecker.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt index bb54f3c5e0f..9212c8f3a80 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirEqualityCompatibilityChecker.kt @@ -384,9 +384,28 @@ private fun FirExpression.toArgumentInfo(context: CheckerContext) = this, resolvedType, mostOriginalTypeIfSmartCast.fullyExpandedType(context.session), context.session, ) +/** + * Unfortunately, intersections in K1 are not + * smart enough: K1 doesn't say that the + * intersection is empty if all the input + * types "can have subtypes". For example, + * K1 thinks that type parameters always + * allow subtypes, so it won't report + * empty intersections for them regardless + * the bounds. + * + * See: [org.jetbrains.kotlin.types.TypeIntersector.intersectTypes] + */ private fun isCaseMissedByK1Intersector(a: TypeInfo, b: TypeInfo) = a.canHaveSubtypesAccordingToK1 && b.canHaveSubtypesAccordingToK1 +/** + * This function simply replicates `if` with + * early returns from the corresponding function + * in K1. + * + * See: [org.jetbrains.kotlin.types.isIncompatibleEnums] + */ private fun isCaseMissedByAdditionalK1IncompatibleEnumsCheck(a: ConeKotlinType, b: ConeKotlinType, session: FirSession): Boolean { return when { !a.isEnum(session) && !b.isEnum(session) -> true