Permalink
Browse files

Fixed the generated C# when an operator returns a template.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information...
ddobrev committed Aug 5, 2017
1 parent 9fdb9a3 commit dd885a7541f529b3f34068d96983c692f8119f99
@@ -2301,7 +2301,7 @@ public void GenerateMethod(Method method, Class @class)
}
else if (method.IsOperator)
{
GenerateOperator(method);
GenerateOperator(method, returnType);
}
else if (method.SynthKind == FunctionSynthKind.AbstractImplCall)
{
@@ -2324,7 +2324,7 @@ public void GenerateMethod(Method method, Class @class)
}
else if (method.IsOperator)
{
GenerateOperator(method);
GenerateOperator(method, returnType);
}
else
{
@@ -2482,7 +2482,7 @@ private string GetVirtualCallDelegate(Method method, Class @class)
return delegateId;
}
private void GenerateOperator(Method method)
private void GenerateOperator(Method method, QualifiedType returnType)
{
if (method.SynthKind == FunctionSynthKind.ComplementOperator)
{
@@ -2533,7 +2533,7 @@ private void GenerateOperator(Method method)
method.OperatorKind == CXXOperatorKind.EqualEqual ? string.Empty : ")");
}
GenerateInternalFunctionCall(method);
GenerateInternalFunctionCall(method, returnType: returnType);
}
private void GenerateClassConstructor(Method method, Class @class)
@@ -799,6 +799,20 @@ public void TestReturnTemplateValue()
}
}
[Test]
public void TestOperatorReturnTemplateValue()
{
using (var dependentValueFields = new DependentValueFields<int>())
{
using (var other = new DependentValueFields<int>())
{
dependentValueFields.DependentValue = 10;
other.DependentValue = 15;
Assert.That((dependentValueFields + other).DependentValue, Is.EqualTo(25));
}
}
}
[Test]
public void TestAbstractImplementatonsInPrimaryAndSecondaryBases()
{
@@ -115,6 +115,7 @@ class DLL_API DependentValueFields
~DependentValueFields();
DependentValueFields& returnInjectedClass();
DependentValueFields returnValue();
DependentValueFields operator+(const DependentValueFields& other);
T getDependentValue();
void setDependentValue(const T& value);
private:
@@ -158,6 +159,14 @@ DependentValueFields<T> DependentValueFields<T>::returnValue()
return *this;
}
template <typename T>
DependentValueFields<T> DependentValueFields<T>::operator+(const DependentValueFields& other)
{
DependentValueFields<T> sum;
sum.field = field + other.field;
return sum;
}
template <typename T>
class DLL_API DependentPointerFields
{

0 comments on commit dd885a7

Please sign in to comment.