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
19
19
20
20
- Fix incorrect dereference of wrapper object in ` tp_repr ` , which may result in a program crash
21
21
- Fix incorrect dereference in params array handling
22
+ - Fix ` object[] ` parameters taking precedence when should not in overload resolution
22
23
23
24
## [ 2.5.0] [ ] - 2020-06-14
24
25
Original file line number Diff line number Diff line change @@ -203,6 +203,16 @@ internal static int ArgPrecedence(Type t)
203
203
return 3000 ;
204
204
}
205
205
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
+
206
216
TypeCode tc = Type . GetTypeCode ( t ) ;
207
217
// TODO: Clean up
208
218
switch ( tc )
@@ -250,16 +260,6 @@ internal static int ArgPrecedence(Type t)
250
260
return 40 ;
251
261
}
252
262
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
-
263
263
return 2000 ;
264
264
}
265
265
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . IO ;
3
+ using System . Linq ;
3
4
using System . Runtime . InteropServices ;
4
5
5
6
namespace Python . Test
@@ -84,7 +85,7 @@ public Type[] TestNullArrayConversion(Type[] v)
84
85
85
86
public static string [ ] TestStringParamsArg ( params string [ ] args )
86
87
{
87
- return args ;
88
+ return args . Concat ( new [ ] { "tail" } ) . ToArray ( ) ;
88
89
}
89
90
90
91
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():
206
206
def test_string_params_args ():
207
207
"""Test use of string params."""
208
208
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
211
211
assert result [0 ] == 'one'
212
212
assert result [1 ] == 'two'
213
213
assert result [2 ] == 'three'
214
+ # ensures params string[] overload takes precedence over params object[]
215
+ assert result [3 ] == 'tail'
214
216
215
217
result = MethodTest .TestStringParamsArg (['one' , 'two' , 'three' ])
216
- assert len (result ) == 3
218
+ assert len (result ) == 4
217
219
assert result [0 ] == 'one'
218
220
assert result [1 ] == 'two'
219
221
assert result [2 ] == 'three'
222
+ assert result [3 ] == 'tail'
220
223
221
224
222
225
def test_object_params_args ():
You can’t perform that action at this time.
0 commit comments