Browse Source

Avoid generating abstract implementations for template classes.

Fixes https://github.com/mono/CppSharp/issues/1268.
pull/1272/head
Joao Matos 6 years ago committed by João Matos
parent
commit
b15ca8827e
  1. 6
      src/Generator/Passes/GenerateAbstractImplementationsPass.cs
  2. 12
      tests/Common/Common.h

6
src/Generator/Passes/GenerateAbstractImplementationsPass.cs

@ -7,8 +7,8 @@ namespace CppSharp.Passes @@ -7,8 +7,8 @@ namespace CppSharp.Passes
/// <summary>
/// This pass generates internal classes that implement abstract classes.
/// When the return type of a function is abstract, these internal
/// classes provide since the real type cannot be resolved while binding
/// an allocatable class that supports proper polymorphism.
/// classes are used instead since the real type cannot be resolved
/// while binding an allocatable class that supports proper polymorphism.
/// </summary>
public class GenerateAbstractImplementationsPass : TranslationUnitPass
{
@ -57,7 +57,7 @@ namespace CppSharp.Passes @@ -57,7 +57,7 @@ namespace CppSharp.Passes
if (@class.CompleteDeclaration != null)
return VisitClassDecl(@class.CompleteDeclaration as Class);
if (@class.IsAbstract)
if (@class.IsAbstract && !@class.IsTemplate)
{
foreach (var ctor in from ctor in @class.Constructors
where ctor.Access == AccessSpecifier.Public

12
tests/Common/Common.h

@ -1537,3 +1537,15 @@ struct DerivedCovariant: public BaseCovariant { @@ -1537,3 +1537,15 @@ struct DerivedCovariant: public BaseCovariant {
return PtrCovariant(new DerivedCovariant());
}
};
// Issue: https://github.com/mono/CppSharp/issues/1268
template <typename T>
class AbstractClassTemplate {
public:
virtual void func() = 0;
};
class DerivedClass: public AbstractClassTemplate<int> {
public:
void func() override {}
};

Loading…
Cancel
Save