提交 74e69473 编写于 作者: J Josh Peterson 提交者: ramanbs-rythmos

Allow different enums as return type in CreateDelegate (case 1288796)

Allow `CreateDelegate` to have return type covariance with methods that
return `enum` or `int` types.

This is from the upstream change at https://github.com/mono/mono/commit/122494330d635205b0a8766deaeafd0d79bd3d60.
上级 1ffd4e7b
......@@ -158,6 +158,17 @@ namespace System
// Delegate covariance
if (!returnType.IsValueType && delReturnType.IsAssignableFrom (returnType))
returnMatch = true;
else
{
bool isDelArgEnum = delReturnType.IsEnum;
bool isArgEnum = returnType.IsEnum;
if (isArgEnum && isDelArgEnum)
returnMatch = Enum.GetUnderlyingType(delReturnType) == Enum.GetUnderlyingType(returnType);
else if (isDelArgEnum && Enum.GetUnderlyingType(delReturnType) == returnType)
returnMatch = true;
else if (isArgEnum && Enum.GetUnderlyingType(returnType) == delReturnType)
returnMatch = true;
}
}
return returnMatch;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册