DynamicMetaObject ResolveOverload(DynamicMetaObject target, DynamicMetaObject[] args, MethodInfo[] methods, BindingRestrictions additionalRestrictions = null)
        {
            OverloadResolver or;
            if (target != null)
            {
                List<DynamicMetaObject> tmp = args.ToList();
                tmp.Insert(0, target);
                args = tmp.ToArray();
                or = this._languageContext.OverloadResolverFactory.CreateOverloadResolver(args, new CallSignature(args.Length), CallTypes.None);
            }
            else
            {
                or = this._languageContext.OverloadResolverFactory.CreateOverloadResolver(args, new CallSignature(args.Length), CallTypes.None);
            }
            BindingTarget bt = or.ResolveOverload(this.Name, methods, NarrowingLevel.None, NarrowingLevel.All);
            BindingRestrictions restrictions = bt.RestrictedArguments != null ? bt.RestrictedArguments.GetAllRestrictions() : BindingRestrictions.Empty;

            if (!bt.Success)
            {
                foreach (DynamicMetaObject mo in args)
                    restrictions = restrictions.Merge(BindingRestrictions.GetTypeRestriction(mo.Expression, mo.GetLimitType()));

                return DefaultBinder.MakeError(or.MakeInvalidParametersError(bt), restrictions, typeof(object));
            }

            if(additionalRestrictions != null)
                restrictions = restrictions.Merge(additionalRestrictions);

            Expression callExpression = bt.MakeExpression();

            if (callExpression.Type == typeof(void))
                callExpression = Expression.Block(new[] { callExpression, Expression.Constant(null) });
            else if (callExpression.Type != typeof(object))
                callExpression = Expression.Convert(callExpression, typeof(object));

            return new DynamicMetaObject(callExpression, restrictions);
        }