From be22078bd1808805d32e81fc20645bb508185e94 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Mon, 24 May 2021 15:01:52 +0300 Subject: [PATCH] Return empty `NotFixedToInferredTypesSubstitutor` if the current substitutor is empty --- .../resolve/calls/inference/BuilderInferenceSession.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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,