From bcf6582af77301cc82a08f487a49642a909a25c2 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Wed, 21 Jul 2021 09:50:13 -0700 Subject: [PATCH] FIR checker: make TypeApproximatorConfiguration.capturedType consistent with others --- .../org/jetbrains/kotlin/types/AbstractTypeApproximator.kt | 2 +- .../jetbrains/kotlin/types/TypeApproximatorConfiguration.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt index 9a94420093b..45ea330595e 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt @@ -271,7 +271,7 @@ abstract class AbstractTypeApproximator( } val baseSubType = type.lowerType() ?: nothingType() - if (conf.capturedType(ctx, type)) { + if (!conf.capturedType(ctx, type)) { /** * Here everything is ok if bounds for this captured type should not be approximated. * But. If such bounds contains some unauthorized types, then we cannot leave this captured type "as is". diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt index 914637e8238..4887991b41c 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt @@ -27,7 +27,7 @@ open class TypeApproximatorConfiguration { open val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean = { false } open fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean = - false // true means that this type we can leave as is + true // false means that this type we can leave as is abstract class AllFlexibleSameValue : TypeApproximatorConfiguration() { abstract val allFlexible: Boolean @@ -60,7 +60,7 @@ open class TypeApproximatorConfiguration { // i.e. will be approximated only approximatedCapturedStatus captured types override fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean = - type.captureStatus(ctx) != approximatedCapturedStatus + type.captureStatus(ctx) == approximatedCapturedStatus override val intersection: IntersectionStrategy get() = IntersectionStrategy.ALLOWED override val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean get() = { true } @@ -86,7 +86,7 @@ open class TypeApproximatorConfiguration { override val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean get() = { true } override val errorType: Boolean get() = true - override fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean = true + override fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean = false } object UpperBoundAwareIntersectionTypeApproximator : AllFlexibleSameValue() {