Skip to content

Commit fbd76ad

Browse files
committed
Fixed the generated C# when a base class is an external specialisation.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent a1327b4 commit fbd76ad

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

src/Generator/Passes/TrimSpecializationsPass.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ private void CheckBasesForSpecialization(Class @class)
190190
{
191191
var specialization = @base.Class as ClassTemplateSpecialization;
192192
if (specialization != null)
193-
AddSpecialization(specialization);
193+
{
194+
if (!ASTUtils.CheckTypeForSpecialization(@base.Type, @class,
195+
AddSpecialization, Context.TypeMaps))
196+
CheckForInternalSpecialization(@class, @base.Type);
197+
}
194198
CheckBasesForSpecialization(@base.Class);
195199
}
196200
}

tests/NamespacesBase/NamespacesBase.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ class TemplateClass
5959
T t;
6060
};
6161

62+
template <typename T>
63+
class TemplateWithIndependentFields
64+
{
65+
public:
66+
void useDependentPointer(const T* t);
67+
};
68+
6269
class DLL_API HasVirtualInCore
6370
{
6471
public:

tests/NamespacesDerived/NamespacesDerived.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ Abstract* Derived2::getAbstract()
6262
return 0;
6363
}
6464

65+
DerivedFromExternalSpecialization::DerivedFromExternalSpecialization()
66+
{
67+
}
68+
69+
DerivedFromExternalSpecialization::~DerivedFromExternalSpecialization()
70+
{
71+
}
72+
6573
HasVirtualInDependency::HasVirtualInDependency()
6674
{
6775
}

tests/NamespacesDerived/NamespacesDerived.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public override void Setup(Driver driver)
1616
{
1717
base.Setup(driver);
1818
driver.Options.GenerateDefaultValuesForArguments = true;
19+
driver.Options.GenerateClassTemplates = true;
1920

2021
driver.Options.Modules[1].IncludeDirs.Add(GetTestsDirectory("NamespacesDerived"));
2122
var @base = "NamespacesBase";

tests/NamespacesDerived/NamespacesDerived.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ class DLL_API HasVirtualInDependency : public HasVirtualInCore
7171
int callManagedOverride();
7272
};
7373

74+
class DLL_API DerivedFromExternalSpecialization : public TemplateWithIndependentFields<Derived>
75+
{
76+
public:
77+
DerivedFromExternalSpecialization();
78+
~DerivedFromExternalSpecialization();
79+
};
80+
7481
class DLL_API DerivedFromSecondaryBaseInDependency : public Derived, public SecondaryBase
7582
{
7683
public:

0 commit comments

Comments
 (0)