| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 24c5af3 commit 4133927
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -512,7 +512,7 @@ static object[] TryConvertArguments(ParameterInfo[] pi, bool paramsArray, | |||
| 512 | 512 | { | |
| 513 | 513 | if(arrayStart == paramIndex) | |
| 514 | 514 | { | |
| 515 | - op = HandleParamsArray(args, arrayStart, pyArgCount, out isNewReference); | ||
| 515 | + op = HandleParamsArray(args, arrayStart, pyArgCount, out isNewReference); | ||
| 516 | 516 | } | |
| 517 | 517 | else | |
| 518 | 518 | { | |
@@ -652,7 +652,7 @@ static bool MatchesArgumentCount(int positionalArgumentCount, ParameterInfo[] pa | |||
| 652 | 652 | { | |
| 653 | 653 | match = true; | |
| 654 | 654 | } | |
| 655 | - else if (positionalArgumentCount < parameters.Length) | ||
| 655 | + else if (positionalArgumentCount < parameters.Length && (!paramsArray || positionalArgumentCount == parameters.Length - 1)) | ||
| 656 | 656 | { | |
| 657 | 657 | // every parameter past 'positionalArgumentCount' must have either | |
| 658 | 658 | // a corresponding keyword argument or a default parameter | |
@@ -677,7 +677,7 @@ static bool MatchesArgumentCount(int positionalArgumentCount, ParameterInfo[] pa | |||
| 677 | 677 | defaultArgList.Add(parameters[v].GetDefaultValue()); | |
| 678 | 678 | defaultsNeeded++; | |
| 679 | 679 | } | |
| 680 | - else if(!paramsArray) | ||
| 680 | + else if (!paramsArray) | ||
| 681 | 681 | { | |
| 682 | 682 | match = false; | |
| 683 | 683 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,4 +48,22 @@ public SubclassConstructorTest(Exception v) | |||
| 48 | 48 | value = v; | |
| 49 | 49 | } | |
| 50 | 50 | } | |
| 51 | + | ||
| 52 | + public class MultipleConstructorsTest | ||
| 53 | + { | ||
| 54 | + public string value; | ||
| 55 | + public Type[] type; | ||
| 56 | + | ||
| 57 | + public MultipleConstructorsTest() | ||
| 58 | + { | ||
| 59 | + value = ""; | ||
| 60 | + type = new Type[1] { null }; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public MultipleConstructorsTest(string s, params Type[] tp) | ||
| 64 | + { | ||
| 65 | + value = s; | ||
| 66 | + type = tp; | ||
| 67 | + } | ||
| 68 | + } | ||
| 51 | 69 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -703,6 +703,16 @@ public static string DefaultParamsWithOverloading(int a = 5, int b = 6, int c = | |||
| 703 | 703 | { | |
| 704 | 704 | return $"{a}{b}{c}{d}XXX"; | |
| 705 | 705 | } | |
| 706 | + | ||
| 707 | + public static string ParamsArrayOverloaded(int i = 1) | ||
| 708 | + { | ||
| 709 | + return "without params-array"; | ||
| 710 | + } | ||
| 711 | + | ||
| 712 | + public static string ParamsArrayOverloaded(int i, params int[] paramsArray) | ||
| 713 | + { | ||
| 714 | + return "with params-array"; | ||
| 715 | + } | ||
| 706 | 716 | } | |
| 707 | 717 | ||
| 708 | 718 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,3 +44,12 @@ class Sub(System.Exception): | |||
| 44 | 44 | instance = Sub() | |
| 45 | 45 | ob = SubclassConstructorTest(instance) | |
| 46 | 46 | assert isinstance(ob.value, System.Exception) | |
| 47 | + | ||
| 48 | + | ||
| 49 | + def test_multiple_constructor(): | ||
| 50 | + from Python.Test import MultipleConstructorsTest | ||
| 51 | + import System | ||
| 52 | + | ||
| 53 | + # Test parameterless | ||
| 54 | + ob = MultipleConstructorsTest() | ||
| 55 | + assert ob.value == "" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1188,3 +1188,36 @@ def test_keyword_arg_method_resolution(): | |||
| 1188 | 1188 | ob = MethodArityTest() | |
| 1189 | 1189 | assert ob.Foo(1, b=2) == "Arity 2" | |
| 1190 | 1190 | ||
| 1191 | + def test_params_array_overload(): | ||
| 1192 | + res = MethodTest.ParamsArrayOverloaded() | ||
| 1193 | + assert res == "without params-array" | ||
| 1194 | + | ||
| 1195 | + res = MethodTest.ParamsArrayOverloaded(1) | ||
| 1196 | + assert res == "without params-array" | ||
| 1197 | + | ||
| 1198 | + res = MethodTest.ParamsArrayOverloaded(i=1) | ||
| 1199 | + assert res == "without params-array" | ||
| 1200 | + | ||
| 1201 | + res = MethodTest.ParamsArrayOverloaded(1, 2) | ||
| 1202 | + assert res == "with params-array" | ||
| 1203 | + | ||
| 1204 | + res = MethodTest.ParamsArrayOverloaded(1, 2, 3) | ||
| 1205 | + assert res == "with params-array" | ||
| 1206 | + | ||
| 1207 | + res = MethodTest.ParamsArrayOverloaded(1, paramsArray=[]) | ||
| 1208 | + assert res == "with params-array" | ||
| 1209 | + | ||
| 1210 | + res = MethodTest.ParamsArrayOverloaded(1, i=1) | ||
| 1211 | + assert res == "with params-array" | ||
| 1212 | + | ||
| 1213 | + res = MethodTest.ParamsArrayOverloaded(1, 2, 3, i=1) | ||
| 1214 | + assert res == "with params-array" | ||
| 1215 | + | ||
| 1216 | + # These two cases are still incorrectly failing: | ||
| 1217 | + | ||
| 1218 | + # res = MethodTest.ParamsArrayOverloaded(1, 2, i=1) | ||
| 1219 | + # assert res == "with params-array" | ||
| 1220 | + | ||
| 1221 | + # res = MethodTest.ParamsArrayOverloaded(paramsArray=[], i=1) | ||
| 1222 | + # assert res == "with params-array" | ||
| 1223 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments