Skip to content

Commit

Permalink
Fixed the getting of base methods to include ignored ones.
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Jul 26, 2017
1 parent cece243 commit e62651a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/AST/ClassExtensions.cs
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/AST/FunctionExtensions.cs
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit e62651a

Please sign in to comment.