Browse Source

Fix template type checking in CovariantTypeComparer.

Fixes https://github.com/mono/CppSharp/issues/1266.
pull/1269/head
Joao Matos 6 years ago committed by João Matos
parent
commit
3409498738
  1. 13
      src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs
  2. 15
      tests/Common/Common.h

13
src/Generator/Passes/CheckVirtualOverrideReturnCovariance.cs

@ -71,6 +71,19 @@ namespace CppSharp.Passes @@ -71,6 +71,19 @@ namespace CppSharp.Passes
return tag.Declaration.Visit(this);
}
public override bool VisitTemplateSpecializationType(TemplateSpecializationType template,
TypeQualifiers quals)
{
if (!currentType.Qualifiers.Equals(quals))
return false;
var currentTemplateType = currentType.Type as TemplateSpecializationType;
if (currentTemplateType == null)
return false;
return currentTemplateType.Equals(template);
}
static bool IsDescendentOf(Class @class, Class parent)
{
return @class == parent ||

15
tests/Common/Common.h

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#endif
#include <string>
#include <vector>
#include <memory>
class DLL_API TestPacking
{
@ -1522,3 +1523,17 @@ struct DLL_API StructWithCopyCtor @@ -1522,3 +1523,17 @@ struct DLL_API StructWithCopyCtor
};
uint16_t DLL_API TestStructWithCopyCtorByValue(StructWithCopyCtor s);
// Issue: https://github.com/mono/CppSharp/issues/1266
struct BaseCovariant;
typedef std::unique_ptr<BaseCovariant> PtrCovariant;
struct BaseCovariant {
virtual PtrCovariant clone() const = 0;
};
struct DerivedCovariant: public BaseCovariant {
std::unique_ptr<BaseCovariant> clone() const override {
return PtrCovariant(new DerivedCovariant());
}
};

Loading…
Cancel
Save