NI: remove separation of variable fixation order by constraint kind
The commit partially reverts ec4d9d2f1f
^KT-37914 Fixed
This commit is contained in:
+7
-17
@@ -54,8 +54,7 @@ class VariableFixationFinder(
|
||||
enum class TypeVariableFixationReadiness {
|
||||
FORBIDDEN,
|
||||
WITHOUT_PROPER_ARGUMENT_CONSTRAINT, // proper constraint from arguments -- not from upper bound for type parameters
|
||||
WITH_COMPLEX_DEPENDENCY_LOWER, // if type variable T has constraint with non fixed type variable inside (non-top-level): Foo<S> <: T
|
||||
WITH_COMPLEX_DEPENDENCY_UPPER, // T <: Foo<S>
|
||||
WITH_COMPLEX_DEPENDENCY, // if type variable T has constraint with non fixed type variable inside (non-top-level): T <: Foo<S>
|
||||
WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS, // proper trivial constraint from arguments, Nothing <: T
|
||||
RELATED_TO_ANY_OUTPUT_TYPE,
|
||||
READY_FOR_FIXATION,
|
||||
@@ -69,8 +68,7 @@ class VariableFixationFinder(
|
||||
!notFixedTypeVariables.contains(variable) ||
|
||||
dependencyProvider.isVariableRelatedToTopLevelType(variable) -> TypeVariableFixationReadiness.FORBIDDEN
|
||||
!variableHasProperArgumentConstraints(variable) -> TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT
|
||||
hasDependencyToOtherTypeVariables(variable, ConstraintKind.LOWER) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY_LOWER
|
||||
hasDependencyToOtherTypeVariables(variable, ConstraintKind.UPPER) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY_UPPER
|
||||
hasDependencyToOtherTypeVariables(variable) -> TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY
|
||||
variableHasTrivialOrNonProperConstraints(variable) -> TypeVariableFixationReadiness.WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS
|
||||
dependencyProvider.isVariableRelatedToAnyOutputType(variable) -> TypeVariableFixationReadiness.RELATED_TO_ANY_OUTPUT_TYPE
|
||||
isReified(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_REIFIED
|
||||
@@ -114,12 +112,6 @@ class VariableFixationFinder(
|
||||
return when (candidateReadiness) {
|
||||
TypeVariableFixationReadiness.FORBIDDEN -> null
|
||||
TypeVariableFixationReadiness.WITHOUT_PROPER_ARGUMENT_CONSTRAINT -> VariableForFixation(candidate, false)
|
||||
TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY_UPPER,
|
||||
TypeVariableFixationReadiness.WITH_COMPLEX_DEPENDENCY_LOWER -> VariableForFixation(
|
||||
candidate,
|
||||
hasProperConstraint = variableHasProperArgumentConstraints(candidate),
|
||||
hasOnlyTrivialProperConstraint = variableHasTrivialOrNonProperConstraints(candidate)
|
||||
)
|
||||
TypeVariableFixationReadiness.WITH_TRIVIAL_OR_NON_PROPER_CONSTRAINTS ->
|
||||
VariableForFixation(candidate, hasProperConstraint = true, hasOnlyTrivialProperConstraint = true)
|
||||
|
||||
@@ -127,15 +119,13 @@ class VariableFixationFinder(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Context.hasDependencyToOtherTypeVariables(typeVariable: TypeConstructorMarker, kind: ConstraintKind): Boolean {
|
||||
private fun Context.hasDependencyToOtherTypeVariables(typeVariable: TypeConstructorMarker): Boolean {
|
||||
for (constraint in notFixedTypeVariables[typeVariable]?.constraints ?: return false) {
|
||||
if (constraint.kind != kind || constraint.kind == ConstraintKind.EQUALITY) continue
|
||||
if (constraint.type.lowerBoundIfFlexible().argumentsCount() != 0
|
||||
&& constraint.type.contains {
|
||||
it.typeConstructor() != typeVariable && notFixedTypeVariables.containsKey(it.typeConstructor())
|
||||
}) {
|
||||
return true
|
||||
val dependencyPresenceCondition = { type: KotlinTypeMarker ->
|
||||
type.typeConstructor() != typeVariable && notFixedTypeVariables.containsKey(type.typeConstructor())
|
||||
}
|
||||
if (constraint.type.lowerBoundIfFlexible().argumentsCount() != 0 && constraint.type.contains(dependencyPresenceCondition))
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user