From 90fcf086bb8897f7eb05bca37924b243b90ecb75 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Fri, 27 Oct 2023 18:52:41 +0200 Subject: [PATCH] NI: Clean things around hasOnlyTrivialProperConstraint - Get rid of unused val and its initialization - Use a bit clearer naming - Simplify the definition of `allConstraintsTrivialOrNonProper` --- .../inference/components/VariableFixationFinder.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt index f9c51d3b820..332c2574473 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt @@ -45,7 +45,6 @@ class VariableFixationFinder( data class VariableForFixation( val variable: TypeConstructorMarker, val hasProperConstraint: Boolean, - val hasOnlyTrivialProperConstraint: Boolean = false ) fun findFirstVariableForFixation( @@ -61,7 +60,7 @@ class VariableFixationFinder( WITHOUT_PROPER_ARGUMENT_CONSTRAINT, // proper constraint from arguments -- not from upper bound for type parameters READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES, WITH_COMPLEX_DEPENDENCY, // if type variable T has constraint with non fixed type variable inside (non-top-level): T <: Foo - WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS, // proper trivial constraint from arguments, Nothing <: T + ALL_CONSTRAINTS_TRIVIAL_OR_NON_PROPER, // proper trivial constraint from arguments, Nothing <: T RELATED_TO_ANY_OUTPUT_TYPE, FROM_INCORPORATION_OF_DECLARED_UPPER_BOUND, READY_FOR_FIXATION_UPPER, @@ -87,7 +86,7 @@ class VariableFixationFinder( TypeVariableFixationReadiness.READY_FOR_FIXATION_DECLARED_UPPER_BOUND_WITH_SELF_TYPES !variableHasProperArgumentConstraints(variable) -> TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT hasDependencyToOtherTypeVariables(variable) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY - variableHasTrivialOrNonProperConstraints(variable) -> TypeVariableFixationReadiness.WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS + allConstraintsTrivialOrNonProper(variable) -> TypeVariableFixationReadiness.ALL_CONSTRAINTS_TRIVIAL_OR_NON_PROPER dependencyProvider.isVariableRelatedToAnyOutputType(variable) -> TypeVariableFixationReadiness.RELATED_TO_ANY_OUTPUT_TYPE variableHasOnlyIncorporatedConstraintsFromDeclaredUpperBound(variable) -> TypeVariableFixationReadiness.FROM_INCORPORATION_OF_DECLARED_UPPER_BOUND @@ -131,10 +130,9 @@ class VariableFixationFinder( } } - private fun Context.variableHasTrivialOrNonProperConstraints(variable: TypeConstructorMarker): Boolean { + private fun Context.allConstraintsTrivialOrNonProper(variable: TypeConstructorMarker): Boolean { return notFixedTypeVariables[variable]?.constraints?.all { constraint -> - val isProperConstraint = isProperArgumentConstraint(constraint) - isProperConstraint && trivialConstraintTypeInferenceOracle.isNotInterestingConstraint(constraint) || !isProperConstraint + trivialConstraintTypeInferenceOracle.isNotInterestingConstraint(constraint) || !isProperArgumentConstraint(constraint) } ?: false } @@ -162,8 +160,6 @@ class VariableFixationFinder( return when (getTypeVariableReadiness(candidate, dependencyProvider)) { TypeVariableFixationReadiness.FORBIDDEN -> null TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT -> VariableForFixation(candidate, false) - TypeVariableFixationReadiness.WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS -> - VariableForFixation(candidate, hasProperConstraint = true, hasOnlyTrivialProperConstraint = true) else -> VariableForFixation(candidate, true) }