Skip to content

Commit e2d0dce

Browse files
committed
Generate valid C# for forwarded specializations
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent c36145b commit e2d0dce

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

src/Generator/AST/Utils.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ private static bool UnsupportedTemplateArgument(
151151
ClassTemplateSpecialization specialization, TemplateArgument a, ITypeMapDatabase typeMaps)
152152
{
153153
if (a.Type.Type == null ||
154-
IsTypeExternal(specialization.TranslationUnit.Module, a.Type.Type))
154+
IsTypeExternal(
155+
specialization.TemplatedDecl.TemplatedDecl.TranslationUnit.Module, a.Type.Type))
155156
return true;
156157

157158
var typeIgnoreChecker = new TypeIgnoreChecker(typeMaps);
@@ -178,7 +179,7 @@ private static ClassTemplateSpecialization GetParentSpecialization(Type type)
178179
{
179180
if (type.TryGetDeclaration(out Declaration declaration))
180181
{
181-
ClassTemplateSpecialization specialization = null;
182+
ClassTemplateSpecialization specialization;
182183
do
183184
{
184185
specialization = declaration as ClassTemplateSpecialization;

tests/NamespacesBase/NamespacesBase.h

+14
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,22 @@ class DLL_API TemplateWithIndependentFields
8080
{
8181
public:
8282
void useDependentPointer(const T* t);
83+
const T& constField() const;
84+
private:
85+
T* t = new T;
8386
};
8487

88+
template <typename T>
89+
const T& TemplateWithIndependentFields<T>::constField() const
90+
{
91+
return *t;
92+
}
93+
94+
template <typename T>
95+
void TemplateWithIndependentFields<T>::useDependentPointer(const T* t)
96+
{
97+
}
98+
8599
class DLL_API HasVirtualInCore
86100
{
87101
public:

tests/NamespacesDerived/Independent.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Derived;
2+
template<typename T> class TemplateWithIndependentFields;
3+
typedef TemplateWithIndependentFields<Derived*> ForwardedInIndependentHeader;

tests/NamespacesDerived/NamespacesDerived.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,7 @@ bool operator<<(const Base& b, const char* str)
110110
{
111111
return false;
112112
}
113+
114+
void forceUseSpecializations(ForwardedInIndependentHeader value)
115+
{
116+
}

tests/NamespacesDerived/NamespacesDerived.h

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../Tests.h"
22
#include "../NamespacesBase/NamespacesBase.h"
3+
#include "Independent.h"
34

45
// Namespace clashes with NamespacesBase.OverlappingNamespace
56
// Test whether qualified names turn out right.
@@ -168,3 +169,5 @@ class TestComments
168169
*/
169170
class LinphoneAddress {};
170171
};
172+
173+
DLL_API void forceUseSpecializations(ForwardedInIndependentHeader value);

0 commit comments

Comments
 (0)