Boo.Lang.Compiler.TypeSystem.CallableResolutionService.CalculateCallableScore C# (CSharp) Method

CalculateCallableScore() private static method

private static CalculateCallableScore ( ICallableType parameterType, ICallableType argType ) : int
parameterType ICallableType
argType ICallableType
return int
        private static int CalculateCallableScore(ICallableType parameterType, ICallableType argType)
        {
            // upcast
            // parameterType == ICallableType, "ThreadStart"
            // argumentType == ICallableType, "Anonymous Closure"
            // RULES:
            // Number of arguments for argumentType && parameterType == same
            // Either: all arguments "IsAssignableFrom"
            //			OR
            //			all arguments == exactly (best case scenario)
            // ExactMatch -- (best case)
            // UpCast -- "not exact match, but very close" (this is OK)
            // ImplicitConversion -- "assignable, but wrong number of parameters / whatever" (boo does the normal thing)

            CallableSignature siggyType = parameterType.GetSignature();
            CallableSignature siggyArg = argType.GetSignature();
            // Ensuring that these callables have same number of arguments.
            // def foo(a, b,c) == { a, b, c| print foobar }
            if (siggyType.Parameters.Length != siggyArg.Parameters.Length)
            {
                return CallableUpCastScore;
            }
            for (int i = 0; i < siggyType.Parameters.Length; i++)
            {
                if (siggyType.Parameters[i].Type != siggyArg.Parameters[i].Type)
                {
                    return CallableImplicitConversionScore;
                }
            }
            return siggyType.ReturnType == siggyArg.ReturnType
                ? CallableExactMatchScore : CallableUpCastScore;
        }