From 7da5acda65b64800c450427f346e638b581d1848 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Tue, 13 Sep 2016 20:05:06 +0300 Subject: [PATCH] Fixed the handling of covariant returned types. Signed-off-by: Dimitar Dobrev --- .../Passes/CheckVirtualOverrideReturnCovariance.cs | 8 +++----- tests/Common/Common.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) 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; };