diff --git a/src/AST/ClassExtensions.cs b/src/AST/ClassExtensions.cs index 66976559..c1f21a27 100644 --- a/src/AST/ClassExtensions.cs +++ b/src/AST/ClassExtensions.cs @@ -41,33 +41,21 @@ namespace CppSharp.AST } } - public static Method GetBaseMethod(this Class @class, Method @override, - bool onlyPrimaryBase = false, bool getTopmost = false) + public static Method GetBaseMethod(this Class @class, Method @override) { foreach (var @base in @class.Bases.Where( - b => b.IsClass && b.Class.OriginalClass != @class && (!onlyPrimaryBase || !b.Class.IsInterface))) + b => b.IsClass && b.Class.OriginalClass != @class && !b.Class.IsInterface)) { var baseClass = @base.Class.OriginalClass ?? @base.Class; - Method baseMethod; - if (!getTopmost) - { - baseMethod = baseClass.GetBaseMethod(@override, onlyPrimaryBase); - if (baseMethod != null) - return baseMethod; - } + Method baseMethod = baseClass.GetBaseMethod(@override); + if (baseMethod != null) + return baseMethod; baseMethod = (from method in baseClass.Methods where @override.CanOverride(method) select method).FirstOrDefault(); if (baseMethod != null) return baseMethod; - - if (getTopmost) - { - baseMethod = (baseClass.GetBaseMethod(@override, onlyPrimaryBase, true)); - if (baseMethod != null) - return baseMethod; - } } return null; } diff --git a/src/AST/FunctionExtensions.cs b/src/AST/FunctionExtensions.cs index 53579798..dafa66a1 100644 --- a/src/AST/FunctionExtensions.cs +++ b/src/AST/FunctionExtensions.cs @@ -81,7 +81,7 @@ namespace CppSharp.AST var @class = method.Namespace as Class; Method rootBaseMethod; return method.IsOverride && - (rootBaseMethod = @class.GetBaseMethod(method, true)) != null && + (rootBaseMethod = @class.GetBaseMethod(method)) != null && rootBaseMethod.IsGenerated && rootBaseMethod.IsVirtual; } diff --git a/src/Generator/Passes/MultipleInheritancePass.cs b/src/Generator/Passes/MultipleInheritancePass.cs index 10d77c93..6084340c 100644 --- a/src/Generator/Passes/MultipleInheritancePass.cs +++ b/src/Generator/Passes/MultipleInheritancePass.cs @@ -181,7 +181,7 @@ namespace CppSharp.Passes OriginalNamespace = @interface, OriginalFunction = method.OriginalFunction }; - var rootBaseMethod = @class.GetBaseMethod(method, true); + var rootBaseMethod = @class.GetBaseMethod(method); if (rootBaseMethod != null && rootBaseMethod.IsDeclared) impl.ExplicitInterfaceImpl = @interface; @class.Methods.Add(impl);