Skip to content

Commit dc27c44

Browse files
committed
Fixed the generated C# for arguments with default values of "nullptr".
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 637018f commit dc27c44

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/Generator/Passes/HandleDefaultParamValuesPass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public override bool VisitFunctionDecl(Function function)
6767
var desugared = type.Desugar();
6868

6969
if (!desugared.IsPrimitiveTypeConvertibleToRef() &&
70-
expression.String == "0")
70+
(expression.String == "0" || expression.String == "nullptr"))
7171
{
7272
result = $"default({desugared})";
7373
return true;

tests/CSharp/CSharp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ MethodsWithDefaultValues::~MethodsWithDefaultValues()
548548
{
549549
}
550550

551-
void MethodsWithDefaultValues::defaultPointer(Foo *ptr)
551+
void MethodsWithDefaultValues::defaultPointer(Foo *ptr1, Foo *ptr2)
552552
{
553553
}
554554

tests/CSharp/CSharp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ class DLL_API MethodsWithDefaultValues : public Quux
391391
MethodsWithDefaultValues(double d, QList<QColor> list = QList<QColor>());
392392
MethodsWithDefaultValues(QRect* pointer, float f = 1, int i = std::numeric_limits<double>::infinity());
393393
~MethodsWithDefaultValues();
394-
void defaultPointer(Foo* ptr = 0);
394+
void defaultPointer(Foo* ptr1 = 0, Foo* ptr2 = nullptr);
395395
void defaultVoidStar(void* ptr = 0);
396396
void defaultValueType(QGenericArgument valueType = QGenericArgument());
397397
void defaultChar(char c = 'a');

0 commit comments

Comments
 (0)