Permalink
Browse files

Fixed the getting of base methods to include ignored ones.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Jul 26, 2017
1 parent cece243 commit e62651a9544b27ff70c83a7f28c7d19673209710
Showing with 9 additions and 6 deletions.
  1. +6 −5 src/AST/ClassExtensions.cs
  2. +3 −1 src/AST/FunctionExtensions.cs
@@ -47,23 +47,24 @@ public static Class GetNonIgnoredRootBase(this Class @class)
foreach (var @base in @class.Bases.Where(
b => b.IsClass && b.Class.OriginalClass != @class && (!onlyPrimaryBase || !b.Class.IsInterface)))
{
var baseClass = @base.Class.OriginalClass ?? @base.Class;
Method baseMethod;
if (!getTopmost)
{
baseMethod = @base.Class.GetBaseMethod(@override, onlyPrimaryBase);
baseMethod = baseClass.GetBaseMethod(@override, onlyPrimaryBase);
if (baseMethod != null)
return baseMethod;
}
baseMethod = (from method in @base.Class.Methods
where @override.CanOverride(method)
select method).FirstOrDefault();
baseMethod = (from method in baseClass.Methods
where @override.CanOverride(method)
select method).FirstOrDefault();
if (baseMethod != null)
return baseMethod;
if (getTopmost)
{
baseMethod = (@base.Class.GetBaseMethod(@override, onlyPrimaryBase, true));
baseMethod = (baseClass.GetBaseMethod(@override, onlyPrimaryBase, true));
if (baseMethod != null)
return baseMethod;
}
@@ -89,7 +89,9 @@ public static bool CanOverride(this Method @override, Method method)
{
return (method.OriginalName == @override.OriginalName &&
method.OriginalReturnType.ResolvesTo(@override.OriginalReturnType) &&
method.Parameters.SequenceEqual(@override.Parameters, ParameterTypeComparer.Instance)) ||
method.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType).SequenceEqual(
@override.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType),
ParameterTypeComparer.Instance)) ||
(@override.IsDestructor && method.IsDestructor && method.IsVirtual);
}
}

0 comments on commit e62651a

Please sign in to comment.