Skip to content

Commit

Permalink
Detail: assert that IsCovariantReturnTypes only gets called for ret…
Browse files Browse the repository at this point in the history
…urn types
  • Loading branch information
stakx committed Dec 29, 2022
1 parent 6238c15 commit ee08309
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Castle.DynamicProxy.Generators
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;

internal class MethodSignatureComparer : IEqualityComparer<MethodInfo>
Expand Down Expand Up @@ -136,6 +137,9 @@ private bool EqualSignatureTypes(Type x, Type y, MethodInfo xm = null, MethodInf

static bool IsCovariantReturnTypes(Type x, Type y, MethodInfo xm, MethodInfo ym)
{
Debug.Assert((xm == null && ym == null)
|| (xm != null && ym != null && x == xm.ReturnType && y == ym.ReturnType));

// This enables covariant method returns for .NET 5 and newer.
// No need to check for runtime support, since such methods are marked with a custom attribute;
// see https://github.com/dotnet/runtime/blob/main/docs/design/features/covariant-return-methods.md.
Expand Down

0 comments on commit ee08309

Please sign in to comment.