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][].
55
66This document follows the conventions laid out in [ Keep a CHANGELOG] [ ] .
77
8+
9+ ## Unreleased
10+
11+ ### Fixed
12+ - Fix ` object[] ` parameters taking precedence when should not in overload resolution
13+
814## [ 2.5.1] [ ] - 2020-06-18
915
1016Bugfix release.
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 @@ -208,17 +208,20 @@ def test_null_array_conversion():
208208def test_string_params_args ():
209209 """Test use of string params."""
210210 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
213213 assert result [0 ] == 'one'
214214 assert result [1 ] == 'two'
215215 assert result [2 ] == 'three'
216+ # ensures params string[] overload takes precedence over params object[]
217+ assert result [3 ] == 'tail'
216218
217219 result = MethodTest .TestStringParamsArg (['one' , 'two' , 'three' ])
218- assert len (result ) == 3
220+ assert len (result ) == 4
219221 assert result [0 ] == 'one'
220222 assert result [1 ] == 'two'
221223 assert result [2 ] == 'three'
224+ assert result [3 ] == 'tail'
222225
223226
224227def test_object_params_args ():
You can’t perform that action at this time.
0 commit comments