From b5111d101e9c9e1f2130b8f1b17a7a9e75f7c723 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 3 Jan 2023 18:19:05 +0100 Subject: [PATCH] ConeTypeIntersector: reuse isNullableType from type context --- .../jetbrains/kotlin/fir/types/ConeTypeIntersector.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeIntersector.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeIntersector.kt index 491a7c92726..c9a8b500f23 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeIntersector.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/ConeTypeIntersector.kt @@ -47,7 +47,9 @@ object ConeTypeIntersector { * UNKNOWN means, that we do not know, i.e. more precisely, all singleClassifier types marked nullable if any, * and other types is captured types or type parameters without not-null upper bound. Example: `String? & T` such types we should leave as is. */ - val isResultNotNullable = inputTypes.any { !it.isNullable(context) } + val isResultNotNullable = with(context) { + inputTypes.any { !it.isNullableType() } + } val inputTypesMadeNotNullIfNeeded = inputTypes.mapTo(LinkedHashSet()) { if (isResultNotNullable) it.makeConeTypeDefinitelyNotNullOrNotNull(context) else it } @@ -91,11 +93,4 @@ object ConeTypeIntersector { private fun ConeKotlinType.isStrictSubtypeOf(context: ConeTypeContext, supertype: ConeKotlinType): Boolean = AbstractTypeChecker.isSubtypeOf(context, this, supertype) && !AbstractTypeChecker.isSubtypeOf(context, supertype, this) - - private fun ConeKotlinType.isNullable(context: ConeTypeContext): Boolean = - when { - isMarkedNullable -> true - this is ConeFlexibleType -> upperBound.isNullable(context) - else -> !ConeNullabilityChecker.isSubtypeOfAny(context, this) - } }