Extract type preparation during type checking to a separate component

This commit is contained in:
Victor Petukhov
2021-05-13 11:32:41 +03:00
parent cba221c18a
commit 2239404085
17 changed files with 171 additions and 105 deletions
@@ -257,6 +257,8 @@ class ConstraintInjector(
}
}
override fun prepareType(type: KotlinTypeMarker) = baseContext.prepareType(type)
fun runIsSubtypeOf(
lowerType: KotlinTypeMarker,
upperType: KotlinTypeMarker,
@@ -74,8 +74,8 @@ fun <T> SimpleConstraintSystem.isSignatureNotLessSpecific(
* Here, when we try solve this CS(Y is variables) then Array<out X> <: Array<out Y> and this system impossible to solve,
* so we capture types from receiver and value parameters.
*/
val specificCapturedType =
context.prepareType(specificType).let { if (captureFromArgument) context.captureFromExpression(it) ?: it else it }
val specificCapturedType = AbstractTypeChecker.prepareType(context, specificType)
.let { if (captureFromArgument) context.captureFromExpression(it) ?: it else it }
addSubtypeConstraint(specificCapturedType, substitutedGeneralType)
}
}
@@ -86,7 +86,7 @@ abstract class AbstractTypeApproximator(
return cachedValue(type, conf, toSuper = true) {
approximateTo(
prepareType(type), conf, { upperBound() },
AbstractTypeChecker.prepareType(ctx, type), conf, { upperBound() },
referenceApproximateToSuperType, depth
)
}
@@ -97,7 +97,7 @@ abstract class AbstractTypeApproximator(
return cachedValue(type, conf, toSuper = false) {
approximateTo(
prepareType(type), conf, { lowerBound() },
AbstractTypeChecker.prepareType(ctx, type), conf, { lowerBound() },
referenceApproximateToSubType, depth
)
}