diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt index 962ce7b3dcc..ba36babcfc1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt @@ -206,8 +206,11 @@ class BuilderInferenceSession( override fun currentConstraintSystem() = ConstraintStorage.Empty - fun getNotFixedToInferredTypesSubstitutor(): NewTypeSubstitutor = - ComposedSubstitutor(commonSystem.buildCurrentSubstitutor() as NewTypeSubstitutor, createNonFixedTypeToVariableSubstitutor()) + fun getNotFixedToInferredTypesSubstitutor(): NewTypeSubstitutor { + val currentSubstitutor = + commonSystem.buildCurrentSubstitutor().cast().takeIf { !it.isEmpty } ?: return EmptySubstitutor + return ComposedSubstitutor(currentSubstitutor, createNonFixedTypeToVariableSubstitutor()) + } override fun inferPostponedVariables( lambda: ResolvedLambdaAtom,