private void EmitCallableResolutionError(Node sourceNode, IEntity[] candidates, ExpressionCollection args)
{
//if this is call without arguments and ambiguous contains generic method without arguments
//than emit BCE0164 for readability
var genericMethod = candidates.OfType<IMethod>().FirstOrDefault(m => m.GenericInfo != null && m.GetParameters().Length == 0);
if (args.Count == 0 && genericMethod != null)
{
Error(CompilerErrorFactory.CannotInferGenericMethodArguments(sourceNode, genericMethod));
return;
}
if (CallableResolutionService.ValidCandidates.Count > 1)
{
Error(CompilerErrorFactory.AmbiguousReference(sourceNode, candidates[0].Name, CallableResolutionService.ValidCandidates.Select(c => (IEntity)c.Method)));
return;
}
var candidate = candidates[0];
var constructor = candidate as IConstructor;
if (constructor != null)
{
Error(CompilerErrorFactory.NoApropriateConstructorFound(sourceNode, constructor.DeclaringType, GetSignature(args)));
}
else
{
Error(CompilerErrorFactory.NoApropriateOverloadFound(sourceNode, GetSignature(args), candidate.FullName));
}
}