Skip to content

Commit 1318d41

Browse files
committed
Fix bug in test code
Can't return `T();` if `T` is a const reference type.
1 parent ed0f9e5 commit 1318d41

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/Generator/Passes/SymbolsCodeGenerator.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ private void WrapConstructor(Method method, string wrapper, string @params)
162162
bool isAbstract = ((Class)method.Namespace).IsAbstract;
163163
if (method.Access == AccessSpecifier.Protected || isAbstract)
164164
{
165-
Write($@"{{ ::new ({Helpers.InstanceField}) {
166-
wrapper}{method.Namespace.Name}({@params}); }}");
165+
Write($@"{{ ::new ({Helpers.InstanceField}) {wrapper}{method.Namespace.Name}({@params}); }}");
167166
WriteLine(!isAbstract ? " };" : string.Empty);
168167
}
169168
else
@@ -210,12 +209,10 @@ private void WrapDestructor(Method method, string wrapper)
210209
{
211210
string @class = wrapper + method.Namespace.Name;
212211
WriteLine($"() {{ this->~{@class}(); }} }};");
213-
Write($@"extern ""C"" {GetExporting()}void {wrapper}({
214-
@class}* {instance}) {{ {instance}->{wrapper}Protected");
212+
Write($@"extern ""C"" {GetExporting()}void {wrapper}({@class}* {instance}) {{ {instance}->{wrapper}Protected");
215213
}
216214
else
217-
Write($@"({$"{@namespace}*{instance}"}) {{ {
218-
instance}->~{method.Namespace.Name}");
215+
Write($@"({$"{@namespace}*{instance}"}) {{ {instance}->~{method.Namespace.Name}");
219216
WriteLine("(); }");
220217
}
221218

@@ -238,8 +235,7 @@ private void TakeFunctionAddress(Function function, string wrapper)
238235

239236
var method = function as Method;
240237
if (function.Namespace.Access == AccessSpecifier.Protected)
241-
Write($@"class {wrapper}{function.Namespace.Name} : public {
242-
function.Namespace.Namespace.Visit(cppTypePrinter)} {{ ");
238+
Write($@"class {wrapper}{function.Namespace.Name} : public {function.Namespace.Namespace.Visit(cppTypePrinter)} {{ ");
243239

244240
string variable = $@"({(method?.IsStatic == false ?
245241
(@namespace + "::") : string.Empty)}*{wrapper}){signature}";

tests/dotnet/CSharp/CSharpTemplates.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const T* ImplReturnPointer<T>::abstractReturnPointer()
7878
template <typename T>
7979
class IndependentFields : public T1
8080
{
81-
typedef T Type;
81+
typedef std::remove_reference_t<std::remove_const_t<T>> Type;
8282

8383
public:
8484
class Nested
@@ -163,9 +163,9 @@ T IndependentFields<T>::getDependent(const T& t)
163163
}
164164

165165
template <typename T>
166-
T IndependentFields<T>::property()
166+
typename IndependentFields<T>::Type IndependentFields<T>::property()
167167
{
168-
return T();
168+
return IndependentFields::Type();
169169
}
170170

171171
template <typename T>

0 commit comments

Comments
 (0)