File tree Expand file tree Collapse file tree 4 files changed +19
-14
lines changed
Expand file tree Collapse file tree 4 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ details about the cause of the failure
1919
2020- Fix incorrect dereference of wrapper object in ` tp_repr ` , which may result in a program crash
2121- Fix incorrect dereference in params array handling
22+ - Fix ` object[] ` parameters taking precedence when should not in overload resolution
2223
2324## [ 2.5.0] [ ] - 2020-06-14
2425
Original file line number Diff line number Diff line change @@ -203,6 +203,16 @@ internal static int ArgPrecedence(Type t)
203203 return 3000 ;
204204 }
205205
206+ if ( t . IsArray )
207+ {
208+ Type e = t . GetElementType ( ) ;
209+ if ( e == objectType )
210+ {
211+ return 2500 ;
212+ }
213+ return 100 + ArgPrecedence ( e ) ;
214+ }
215+
206216 TypeCode tc = Type . GetTypeCode ( t ) ;
207217 // TODO: Clean up
208218 switch ( tc )
@@ -250,16 +260,6 @@ internal static int ArgPrecedence(Type t)
250260 return 40 ;
251261 }
252262
253- if ( t . IsArray )
254- {
255- Type e = t . GetElementType ( ) ;
256- if ( e == objectType )
257- {
258- return 2500 ;
259- }
260- return 100 + ArgPrecedence ( e ) ;
261- }
262-
263263 return 2000 ;
264264 }
265265
Original file line number Diff line number Diff line change 11using System ;
22using System . IO ;
3+ using System . Linq ;
34using System . Runtime . InteropServices ;
45
56namespace Python . Test
@@ -84,7 +85,7 @@ public Type[] TestNullArrayConversion(Type[] v)
8485
8586 public static string [ ] TestStringParamsArg ( params string [ ] args )
8687 {
87- return args ;
88+ return args . Concat ( new [ ] { "tail" } ) . ToArray ( ) ;
8889 }
8990
9091 public static object [ ] TestObjectParamsArg ( params object [ ] args )
Original file line number Diff line number Diff line change @@ -206,17 +206,20 @@ def test_null_array_conversion():
206206def test_string_params_args ():
207207 """Test use of string params."""
208208 result = MethodTest .TestStringParamsArg ('one' , 'two' , 'three' )
209- assert result .Length == 3
210- assert len (result ) == 3 , result
209+ assert result .Length == 4
210+ assert len (result ) == 4 , result
211211 assert result [0 ] == 'one'
212212 assert result [1 ] == 'two'
213213 assert result [2 ] == 'three'
214+ # ensures params string[] overload takes precedence over params object[]
215+ assert result [3 ] == 'tail'
214216
215217 result = MethodTest .TestStringParamsArg (['one' , 'two' , 'three' ])
216- assert len (result ) == 3
218+ assert len (result ) == 4
217219 assert result [0 ] == 'one'
218220 assert result [1 ] == 'two'
219221 assert result [2 ] == 'three'
222+ assert result [3 ] == 'tail'
220223
221224
222225def test_object_params_args ():
You can’t perform that action at this time.
0 commit comments