Skip to content

Commit b15ca88

Browse files
committed
Avoid generating abstract implementations for template classes.
Fixes #1268.
1 parent 3409498 commit b15ca88

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/Generator/Passes/GenerateAbstractImplementationsPass.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace CppSharp.Passes
77
/// <summary>
88
/// This pass generates internal classes that implement abstract classes.
99
/// When the return type of a function is abstract, these internal
10-
/// classes provide since the real type cannot be resolved while binding
11-
/// an allocatable class that supports proper polymorphism.
10+
/// classes are used instead since the real type cannot be resolved
11+
/// while binding an allocatable class that supports proper polymorphism.
1212
/// </summary>
1313
public class GenerateAbstractImplementationsPass : TranslationUnitPass
1414
{
@@ -57,7 +57,7 @@ public override bool VisitClassDecl(Class @class)
5757
if (@class.CompleteDeclaration != null)
5858
return VisitClassDecl(@class.CompleteDeclaration as Class);
5959

60-
if (@class.IsAbstract)
60+
if (@class.IsAbstract && !@class.IsTemplate)
6161
{
6262
foreach (var ctor in from ctor in @class.Constructors
6363
where ctor.Access == AccessSpecifier.Public

tests/Common/Common.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,3 +1537,15 @@ struct DerivedCovariant: public BaseCovariant {
15371537
return PtrCovariant(new DerivedCovariant());
15381538
}
15391539
};
1540+
1541+
// Issue: https://github.com/mono/CppSharp/issues/1268
1542+
template <typename T>
1543+
class AbstractClassTemplate {
1544+
public:
1545+
virtual void func() = 0;
1546+
};
1547+
1548+
class DerivedClass: public AbstractClassTemplate<int> {
1549+
public:
1550+
void func() override {}
1551+
};

0 commit comments

Comments
 (0)