-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
If a virtual method has a modreq on one of the parameters, but a child type overrides this method without having the modreq, the CLR considers them two different signatures, and they don't override each other, which leads to the following behavior:
Signature of the virtual Parent.M(in int):
.method public hidebysig newslot virtual instance string M ([in] int32& modreq([mscorlib]System.Runtime.InteropServices.InAttribute) x) cil managed
Signature of the overriding Child.M(in int):
.method public hidebysig virtual instance string M ([in] int32& x) cil managed
User code:
namespace clrbug
{
class Program
{
static void Main(string[] args)
{
Test(new Parent());
Test(new Child());
}
static void Test(Parent obj)
{
Console.WriteLine(obj.M(0));
}
}
}On CoreCLR:
dotnet clrbug.dll
Parent
Parent
On Mono:
mono clrbug.dll
Parent
Child
Here are the two binaries, the one that has that IL, and the console application: monobug.zip