NI: Do not use asConstraintSystemCompleterContext before completion

This commit is contained in:
Denis.Zharkov
2021-12-24 09:28:30 +03:00
committed by teamcity
parent 1d258635a2
commit 62673c7e1b
2 changed files with 8 additions and 10 deletions
@@ -117,7 +117,7 @@ object CollectTypeVariableUsagesInfo : ResolutionStage() {
return dependentTypeParameters.any { (typeParameter, _) ->
returnType.contains {
it.typeConstructor(asConstraintSystemCompleterContext()) == getTypeParameterByVariable(typeParameter) && !it.isMarkedNullable()
it.typeConstructor(this) == getTypeParameterByVariable(typeParameter) && !it.isMarkedNullable()
}
}
}
@@ -125,7 +125,7 @@ object CollectTypeVariableUsagesInfo : ResolutionStage() {
private fun NewConstraintSystemImpl.getDependentTypeParameters(
variable: TypeConstructorMarker,
dependentTypeParametersSeen: List<Pair<TypeConstructorMarker, ConeKotlinType?>> = listOf()
): List<Pair<ConeTypeVariableTypeConstructor, ConeKotlinType?>> = with(asConstraintSystemCompleterContext()) {
): List<Pair<ConeTypeVariableTypeConstructor, ConeKotlinType?>> {
val dependentTypeParameters = getBuilder().currentStorage().notFixedTypeVariables.asSequence()
.flatMap { (typeConstructor, constraints) ->
require(typeConstructor is ConeTypeVariableTypeConstructor)
@@ -170,13 +170,11 @@ object CollectTypeVariableUsagesInfo : ResolutionStage() {
(getBuilder().currentStorage().allTypeVariables[typeConstructor] as? ConeTypeParameterBasedTypeVariable)?.typeParameterSymbol?.toLookupTag()
private fun NewConstraintSystemImpl.getDependingOnTypeParameter(variable: TypeConstructorMarker): List<ConeTypeVariableTypeConstructor> =
with(asConstraintSystemCompleterContext()) {
getBuilder().currentStorage().notFixedTypeVariables[variable]?.constraints?.mapNotNull {
if (it.position.from is ConeDeclaredUpperBoundConstraintPosition && it.kind == ConstraintKind.UPPER) {
it.type.typeConstructor() as? ConeTypeVariableTypeConstructor
} else null
} ?: emptyList()
}
getBuilder().currentStorage().notFixedTypeVariables[variable]?.constraints?.mapNotNull {
if (it.position.from is ConeDeclaredUpperBoundConstraintPosition && it.kind == ConstraintKind.UPPER) {
it.type.typeConstructor() as? ConeTypeVariableTypeConstructor
} else null
} ?: emptyList()
private fun ConeTypeVariable.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter() {
this.typeConstructor.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter()
@@ -193,7 +193,7 @@ class FirCallCompleter(
val csBuilder = candidate.system.getBuilder()
csBuilder.registerVariable(returnVariable)
val functionalType = csBuilder.buildCurrentSubstitutor()
.safeSubstitute(csBuilder.asConstraintSystemCompleterContext(), atom.expectedType!!) as ConeClassLikeType
.safeSubstitute(csBuilder, atom.expectedType!!) as ConeClassLikeType
val size = functionalType.typeArguments.size
val expectedType = ConeClassLikeTypeImpl(
functionalType.lookupTag,