Skip to content

Commit

Permalink
Minimal bugfix (draft)
Browse files Browse the repository at this point in the history
  • Loading branch information
stakx committed May 13, 2022
1 parent 50241be commit 16bf56b
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public bool EqualParameters(MethodInfo x, MethodInfo y)
return true;
}

public bool EqualSignatureTypes(Type x, Type y)
public bool EqualSignatureTypes(Type x, Type y, bool precise = true)
{
if (x.IsGenericParameter != y.IsGenericParameter)
{
Expand Down Expand Up @@ -122,6 +122,11 @@ public bool EqualSignatureTypes(Type x, Type y)
{
if (!x.Equals(y))
{
if (!precise && y.IsAssignableFrom(x)) // covariant returns in .NET 6+
{
return true;
}

return false;
}
}
Expand All @@ -142,7 +147,7 @@ public bool Equals(MethodInfo x, MethodInfo y)

return EqualNames(x, y) &&
EqualGenericParameters(x, y) &&
EqualSignatureTypes(x.ReturnType, y.ReturnType) &&
EqualSignatureTypes(x.ReturnType, y.ReturnType, precise: false) &&
EqualParameters(x, y);
}

Expand Down

0 comments on commit 16bf56b

Please sign in to comment.