diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CollectTypeVariableUsagesInfo.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CollectTypeVariableUsagesInfo.kt index 426c631ad88..6a98571ffdb 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CollectTypeVariableUsagesInfo.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CollectTypeVariableUsagesInfo.kt @@ -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> = listOf() - ): List> = with(asConstraintSystemCompleterContext()) { + ): List> { 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 = - 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() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt index cb2c308cfdb..795c1182dea 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt @@ -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,