Skip to content

Commit

Permalink
Fixed devirtualization at matching between standard method and explic…
Browse files Browse the repository at this point in the history
…itly implemented interface method. #104

#104 (review)
  • Loading branch information
kekyo committed Oct 20, 2021
1 parent 65ebbbe commit 19bb2ea
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions IL2C.Core/Metadata/MetadataUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,27 +473,31 @@ public int Compare(IMethodInformation x, IMethodInformation y)

public bool Equals(IMethodInformation x, IMethodInformation y)
{
var xname = x.Name;
var yname = y.Name;

if (xname != yname)
// Try strictly matching when both class/value type member method
// and explicitly implemented interface method are same.
if (!x.DeclaringType.IsInterface && y.DeclaringType.IsInterface)
{
// If it is an explicit interface implementation, we need to compare with it's full name
if (x.DeclaringType.IsInterface)
if (x.Overrides.Contains(y))
{
xname = $"{x.DeclaringType.FriendlyName}.{xname}";
}
if (y.DeclaringType.IsInterface)
{
yname = $"{y.DeclaringType.FriendlyName}.{yname}";
return true;
}

if (xname != yname)
}
if (x.DeclaringType.IsInterface && !y.DeclaringType.IsInterface)
{
if (y.Overrides.Contains(x))
{
return false;
return true;
}
}

var xname = x.Name;
var yname = y.Name;

if (xname != yname)
{
return false;
}

var xps = x.Parameters;
var yps = y.Parameters;

Expand Down

0 comments on commit 19bb2ea

Please sign in to comment.