@@ -79,7 +79,7 @@ public bool EqualParameters(MethodInfo x, MethodInfo y)
7979 return true ;
8080 }
8181
82- public bool EqualSignatureTypes ( Type x , Type y , MethodInfo xm = null )
82+ public bool EqualSignatureTypes ( Type x , Type y , MethodInfo xm = null , MethodInfo ym = null )
8383 {
8484 if ( x . IsGenericParameter != y . IsGenericParameter )
8585 {
@@ -127,9 +127,10 @@ public bool EqualSignatureTypes(Type x, Type y, MethodInfo xm = null)
127127 // This enables covariant method returns for .NET 5 and newer.
128128 // No need to check for runtime support, since such methods are marked with a custom attribute;
129129 // see https://github.com/dotnet/runtime/blob/main/docs/design/features/covariant-return-methods.md.
130- if ( xm != null && preserveBaseOverridesAttribute != null && xm . IsDefined ( preserveBaseOverridesAttribute , inherit : false ) )
130+ if ( preserveBaseOverridesAttribute != null )
131131 {
132- return y . IsAssignableFrom ( x ) ;
132+ return ( xm != null && xm . IsDefined ( preserveBaseOverridesAttribute , inherit : false ) && y . IsAssignableFrom ( x ) )
133+ || ( ym != null && ym . IsDefined ( preserveBaseOverridesAttribute , inherit : false ) && x . IsAssignableFrom ( y ) ) ;
133134 }
134135
135136 return false ;
@@ -152,7 +153,7 @@ public bool Equals(MethodInfo x, MethodInfo y)
152153
153154 return EqualNames ( x , y ) &&
154155 EqualGenericParameters ( x , y ) &&
155- EqualSignatureTypes ( x . ReturnType , y . ReturnType , x ) &&
156+ EqualSignatureTypes ( x . ReturnType , y . ReturnType , x , y ) &&
156157 EqualParameters ( x , y ) ;
157158 }
158159
0 commit comments