diff --git a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs index 65eafa71..5ba3ee3a 100644 --- a/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs +++ b/src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs @@ -74,10 +74,8 @@ namespace CppSharp.Passes static bool IsDescendentOf(Class @class, Class parent) { - if (!@class.HasBaseClass) - return @class == parent; - - return IsDescendentOf(@class.BaseClass, parent); + return @class == parent || + (@class.HasBaseClass && IsDescendentOf(@class.BaseClass, parent)); } public bool VisitClassDecl(Class @class) @@ -322,7 +320,7 @@ namespace CppSharp.Passes /// public class CheckVirtualOverrideReturnCovariance : TranslationUnitPass { - public override bool VisitMethodDecl(AST.Method method) + public override bool VisitMethodDecl(Method method) { if (!VisitDeclaration(method)) return false; diff --git a/tests/Common/Common.h b/tests/Common/Common.h index 28887da0..1608eaca 100644 --- a/tests/Common/Common.h +++ b/tests/Common/Common.h @@ -240,7 +240,7 @@ typedef Exception Ex1; struct DerivedException; typedef DerivedException Ex2; -struct DLL_API Exception +struct DLL_API Exception : public Foo { virtual Ex1* clone() = 0; };