File tree Expand file tree Collapse file tree 4 files changed +24
-14
lines changed Expand file tree Collapse file tree 4 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ project adheres to [Semantic Versioning][].
5
5
6
6
This document follows the conventions laid out in [ Keep a CHANGELOG] [ ] .
7
7
8
+
9
+ ## Unreleased
10
+
11
+ ### Fixed
12
+ - Fix ` object[] ` parameters taking precedence when should not in overload resolution
13
+
8
14
## [ 2.5.1] [ ] - 2020-06-18
9
15
10
16
Bugfix release.
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 @@ -208,17 +208,20 @@ def test_null_array_conversion():
208
208
def test_string_params_args ():
209
209
"""Test use of string params."""
210
210
result = MethodTest .TestStringParamsArg ('one' , 'two' , 'three' )
211
- assert result .Length == 3
212
- assert len (result ) == 3 , result
211
+ assert result .Length == 4
212
+ assert len (result ) == 4 , result
213
213
assert result [0 ] == 'one'
214
214
assert result [1 ] == 'two'
215
215
assert result [2 ] == 'three'
216
+ # ensures params string[] overload takes precedence over params object[]
217
+ assert result [3 ] == 'tail'
216
218
217
219
result = MethodTest .TestStringParamsArg (['one' , 'two' , 'three' ])
218
- assert len (result ) == 3
220
+ assert len (result ) == 4
219
221
assert result [0 ] == 'one'
220
222
assert result [1 ] == 'two'
221
223
assert result [2 ] == 'three'
224
+ assert result [3 ] == 'tail'
222
225
223
226
224
227
def test_object_params_args ():
You can’t perform that action at this time.
0 commit comments