protected int CalculateArgumentScore(IParameter param, IType parameterType, Node arg)
{
IType argumentType = ArgumentType(arg);
if (param.IsByRef)
{
if (IsValidByRefArg(param, parameterType, argumentType, arg))
{
return ExactMatchScore;
}
return -1;
}
else if (parameterType == argumentType
|| (TypeSystemServices.IsSystemObject(argumentType) &&
TypeSystemServices.IsSystemObject(parameterType)))
{
return parameterType is ICallableType
? CallableExactMatchScore
: ExactMatchScore;
}
else if (parameterType.IsAssignableFrom(argumentType))
{
ICallableType callableType = parameterType as ICallableType;
ICallableType callableArg = argumentType as ICallableType;
if (callableType != null && callableArg != null)
{
return CalculateCallableScore(callableType, callableArg);
}
return UpCastScore;
}
else if (TypeSystemServices.FindImplicitConversionOperator(argumentType, parameterType) != null)
{
return ImplicitConversionScore;
}
else if (TypeSystemServices.CanBeReachedByPromotion(parameterType, argumentType))
{
if (IsWideningPromotion(parameterType, argumentType)) return WideningPromotion;
return NarrowingPromotion;
}
else if (TypeSystemServices.CanBeReachedByDowncast(parameterType, argumentType))
{
return DowncastScore;
}
return -1;
}