Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 07528df

Browse files
committed
remove CanChangePrimitiveObjectToType
1 parent c7ac0ef commit 07528df

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/System.Private.CoreLib/shared/System/DefaultBinder.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public sealed override MethodBase BindToMethod(
217217
// now do a "classic" type check
218218
if (pCls.IsPrimitive)
219219
{
220-
if (argTypes[paramOrder[i][j]] == null || !CanChangePrimitiveObjectToType(args[paramOrder[i][j]], pCls))
220+
if (argTypes[paramOrder[i][j]] == null || !CanChangePrimitive(args[paramOrder[i][j]].GetType(), pCls))
221221
{
222222
break;
223223
}
@@ -247,7 +247,7 @@ public sealed override MethodBase BindToMethod(
247247
{
248248
if (paramArrayType.IsPrimitive)
249249
{
250-
if (argTypes[j] == null || !CanChangePrimitiveObjectToType(args[j], paramArrayType))
250+
if (argTypes[j] == null || !CanChangePrimitive(args[j]?.GetType(), paramArrayType))
251251
break;
252252
}
253253
else
@@ -475,7 +475,7 @@ public sealed override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo
475475
}
476476
if (pCls.IsPrimitive)
477477
{
478-
if (CanChangePrimitiveObjectToType(value, pCls))
478+
if (CanChangePrimitive(valueType, pCls))
479479
{
480480
candidates[CurIdx++] = candidates[i];
481481
continue;
@@ -1218,11 +1218,6 @@ internal static bool CanChangePrimitive(Type source, Type target)
12181218
return (widerCodes & targetCode) != 0;
12191219
}
12201220

1221-
private static bool CanChangePrimitiveObjectToType(object source, Type type)
1222-
{
1223-
return source == null || CanChangePrimitive(source.GetType(), type);
1224-
}
1225-
12261221
private static readonly Primitives[] s_primitiveConversions = {
12271222
/* Empty */ 0, // not primitive
12281223
/* Object */ 0, // not primitive

0 commit comments

Comments
 (0)