private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> completeTypeInferenceDependentOnExpectedType( @NotNull BasicCallResolutionContext context, @NotNull OverloadResolutionResultsImpl<D> results, @NotNull TracingStrategy tracing) { if (results.isSingleResult()) { argumentTypeResolver.checkUnmappedArgumentTypes( context, results .getResultingCall() .getCallToCompleteTypeArgumentInference() .getUnmappedArguments()); } if (!results.isSingleResult()) return results; ResolvedCallImpl<D> resolvedCall = results.getResultingCall().getCallToCompleteTypeArgumentInference(); if (!resolvedCall.hasIncompleteTypeParameters()) { CallCandidateResolutionContext<D> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(resolvedCall, context, tracing); candidateResolver.completeNestedCallsInference(callCandidateResolutionContext); candidateResolver.checkValueArgumentTypes(callCandidateResolutionContext); return results; } ResolvedCallImpl<D> copy = CallResolverUtil.copy(resolvedCall, context); CallCandidateResolutionContext<D> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(copy, context, tracing); candidateResolver.completeTypeInferenceDependentOnExpectedTypeForCall( callCandidateResolutionContext, false); if (copy.getStatus().isSuccess()) { return OverloadResolutionResultsImpl.success(copy); } return OverloadResolutionResultsImpl.incompleteTypeInference(copy); }