Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteaed5c2

Browse files
committed
fixobject[] parameters taking precedence when should not in overload resolution
1 parent61d1b7c commiteaed5c2

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

‎CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

‎src/runtime/methodbinder.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ internal static int ArgPrecedence(Type t)
203203
return3000;
204204
}
205205

206+
if(t.IsArray)
207+
{
208+
Typee=t.GetElementType();
209+
if(e==objectType)
210+
{
211+
return2500;
212+
}
213+
return100+ArgPrecedence(e);
214+
}
215+
206216
TypeCodetc=Type.GetTypeCode(t);
207217
// TODO: Clean up
208218
switch(tc)
@@ -250,16 +260,6 @@ internal static int ArgPrecedence(Type t)
250260
return40;
251261
}
252262

253-
if(t.IsArray)
254-
{
255-
Typee=t.GetElementType();
256-
if(e==objectType)
257-
{
258-
return2500;
259-
}
260-
return100+ArgPrecedence(e);
261-
}
262-
263263
return2000;
264264
}
265265

‎src/testing/methodtest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
usingSystem;
22
usingSystem.IO;
3+
usingSystem.Linq;
34
usingSystem.Runtime.InteropServices;
45

56
namespacePython.Test
@@ -84,7 +85,7 @@ public Type[] TestNullArrayConversion(Type[] v)
8485

8586
publicstaticstring[]TestStringParamsArg(paramsstring[]args)
8687
{
87-
returnargs;
88+
returnargs.Concat(new[]{"tail"}).ToArray();
8889
}
8990

9091
publicstaticobject[]TestObjectParamsArg(paramsobject[]args)

‎src/tests/test_method.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,20 @@ def test_null_array_conversion():
206206
deftest_string_params_args():
207207
"""Test use of string params."""
208208
result=MethodTest.TestStringParamsArg('one','two','three')
209-
assertresult.Length==3
210-
assertlen(result)==3,result
209+
assertresult.Length==4
210+
assertlen(result)==4,result
211211
assertresult[0]=='one'
212212
assertresult[1]=='two'
213213
assertresult[2]=='three'
214+
# ensures params string[] overload takes precedence over params object[]
215+
assertresult[3]=='tail'
214216

215217
result=MethodTest.TestStringParamsArg(['one','two','three'])
216-
assertlen(result)==3
218+
assertlen(result)==4
217219
assertresult[0]=='one'
218220
assertresult[1]=='two'
219221
assertresult[2]=='three'
222+
assertresult[3]=='tail'
220223

221224

222225
deftest_object_params_args():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp