| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -698,11 +698,18 @@ static bool MatchesArgumentCount(int pynargs, ParameterInfo[] parameters, | |||
| 698 | 698 | } | |
| 699 | 699 | else if (pynargs < clrnargs && (!paramsArray || pynargs == clrnargs - 1)) | |
| 700 | 700 | { | |
| 701 | + match = true; | ||
| 702 | + // operator methods will have 2 CLR args but only one Python arg, since | ||
| 703 | + // Python operator methods are bound | ||
| 704 | + if (isOperator) | ||
| 705 | + { | ||
| 706 | + // return early since a C# operator method cannot have | ||
| 707 | + // keyword args, default args, or params arrays (exclusive cases) | ||
| 708 | + return match; | ||
| 709 | + } | ||
| 701 | 710 | // every parameter past 'positionalArgumentCount' must have either | |
| 702 | 711 | // a corresponding keyword argument or a default parameter, unless | |
| 703 | - // the method is an operator or accepts a params array (which cannot | ||
| 704 | - // have a default value) | ||
| 705 | - match = true; | ||
| 712 | + // the method accepts a params array (which cannot have a default value). | ||
| 706 | 713 | defaultArgList = new ArrayList(); | |
| 707 | 714 | for (var v = pynargs; v < clrnargs; v++) | |
| 708 | 715 | { | |
@@ -723,18 +730,11 @@ static bool MatchesArgumentCount(int pynargs, ParameterInfo[] parameters, | |||
| 723 | 730 | defaultArgList.Add(parameters[v].GetDefaultValue()); | |
| 724 | 731 | defaultsNeeded++; | |
| 725 | 732 | } | |
| 726 | - else if (!isOperator && !paramsArray) | ||
| 733 | + else if (!paramsArray) | ||
| 727 | 734 | { | |
| 728 | - // this is separate above because an operator method cannot have | ||
| 729 | - // keyword args, default args, or params arrays (exclusive cases) | ||
| 730 | 735 | match = false; | |
| 731 | 736 | } | |
| 732 | 737 | } | |
| 733 | - if (isOperator && defaultArgList.Count == 0) | ||
| 734 | - { | ||
| 735 | - // If no default arguments were provided for an operable object. | ||
| 736 | - defaultArgList = null; | ||
| 737 | - } | ||
| 738 | 738 | } | |
| 739 | 739 | else if (pynargs > clrnargs && clrnargs > 0 && | |
| 740 | 740 | Attribute.IsDefined(parameters[clrnargs - 1], typeof(ParamArrayAttribute))) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments