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, _) -> return dependentTypeParameters.any { (typeParameter, _) ->
returnType.contains { 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( private fun NewConstraintSystemImpl.getDependentTypeParameters(
variable: TypeConstructorMarker, variable: TypeConstructorMarker,
dependentTypeParametersSeen: List<Pair<TypeConstructorMarker, ConeKotlinType?>> = listOf() dependentTypeParametersSeen: List<Pair<TypeConstructorMarker, ConeKotlinType?>> = listOf()
): List<Pair<ConeTypeVariableTypeConstructor, ConeKotlinType?>> = with(asConstraintSystemCompleterContext()) { ): List<Pair<ConeTypeVariableTypeConstructor, ConeKotlinType?>> {
val dependentTypeParameters = getBuilder().currentStorage().notFixedTypeVariables.asSequence() val dependentTypeParameters = getBuilder().currentStorage().notFixedTypeVariables.asSequence()
.flatMap { (typeConstructor, constraints) -> .flatMap { (typeConstructor, constraints) ->
require(typeConstructor is ConeTypeVariableTypeConstructor) require(typeConstructor is ConeTypeVariableTypeConstructor)
@@ -170,13 +170,11 @@ object CollectTypeVariableUsagesInfo : ResolutionStage() {
(getBuilder().currentStorage().allTypeVariables[typeConstructor] as? ConeTypeParameterBasedTypeVariable)?.typeParameterSymbol?.toLookupTag() (getBuilder().currentStorage().allTypeVariables[typeConstructor] as? ConeTypeParameterBasedTypeVariable)?.typeParameterSymbol?.toLookupTag()
private fun NewConstraintSystemImpl.getDependingOnTypeParameter(variable: TypeConstructorMarker): List<ConeTypeVariableTypeConstructor> = private fun NewConstraintSystemImpl.getDependingOnTypeParameter(variable: TypeConstructorMarker): List<ConeTypeVariableTypeConstructor> =
with(asConstraintSystemCompleterContext()) { getBuilder().currentStorage().notFixedTypeVariables[variable]?.constraints?.mapNotNull {
getBuilder().currentStorage().notFixedTypeVariables[variable]?.constraints?.mapNotNull { if (it.position.from is ConeDeclaredUpperBoundConstraintPosition && it.kind == ConstraintKind.UPPER) {
if (it.position.from is ConeDeclaredUpperBoundConstraintPosition && it.kind == ConstraintKind.UPPER) { it.type.typeConstructor() as? ConeTypeVariableTypeConstructor
it.type.typeConstructor() as? ConeTypeVariableTypeConstructor } else null
} else null } ?: emptyList()
} ?: emptyList()
}
private fun ConeTypeVariable.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter() { private fun ConeTypeVariable.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter() {
this.typeConstructor.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter() this.typeConstructor.recordInfoAboutTypeVariableUsagesAsInvariantOrContravariantParameter()
@@ -193,7 +193,7 @@ class FirCallCompleter(
val csBuilder = candidate.system.getBuilder() val csBuilder = candidate.system.getBuilder()
csBuilder.registerVariable(returnVariable) csBuilder.registerVariable(returnVariable)
val functionalType = csBuilder.buildCurrentSubstitutor() val functionalType = csBuilder.buildCurrentSubstitutor()
.safeSubstitute(csBuilder.asConstraintSystemCompleterContext(), atom.expectedType!!) as ConeClassLikeType .safeSubstitute(csBuilder, atom.expectedType!!) as ConeClassLikeType
val size = functionalType.typeArguments.size val size = functionalType.typeArguments.size
val expectedType = ConeClassLikeTypeImpl( val expectedType = ConeClassLikeTypeImpl(
functionalType.lookupTag, functionalType.lookupTag,