Skip to content

Commit 08d8a1c

Browse files
Fix for fn call when def argument is interface.
1 parent f6210f6 commit 08d8a1c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Generator/Passes/HandleDefaultParamValuesPass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private bool CheckForEnumValue(Type desugared, Statement statement,
243243
if (enumItem != null)
244244
{
245245
result = string.Format("{0}{1}.{2}",
246-
desugared.IsPrimitiveType() ? "(int) " : string.Empty,
246+
desugared.IsPrimitiveType() ? "(int) " : "(" + desugared.CSharpType(new CSharpTypePrinter(Driver)) + ") ",
247247
new CSharpTypePrinter(Driver).VisitEnumDecl(
248248
(Enumeration) enumItem.Namespace), enumItem.Name);
249249
return true;

tests/CSharp/CSharp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ Bar::Bar(Qux qux)
143143
{
144144
}
145145

146+
Bar::Bar(Items item)
147+
{
148+
}
149+
146150
int Bar::method()
147151
{
148152
return 2;
@@ -471,6 +475,10 @@ void MethodsWithDefaultValues::defaultImplicitCtorEnum(Baz arg)
471475
{
472476
}
473477

478+
void MethodsWithDefaultValues::defaultImplicitCtorEnumTwo(Bar arg)
479+
{
480+
}
481+
474482
void MethodsWithDefaultValues::defaultIntWithLongExpression(unsigned int i)
475483
{
476484
}

tests/CSharp/CSharp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class DLL_API Bar : public Qux
6363
};
6464
Bar();
6565
Bar(Qux qux);
66+
Bar(Items item);
6667
int method();
6768
const Foo& operator[](int i) const;
6869
Foo& operator[](int i);
@@ -364,6 +365,7 @@ class DLL_API MethodsWithDefaultValues : public Quux
364365
// in this case the arg is a MaterializeTemporaryExpr, in the other not
365366
// I cannot see the difference but it's there so we need both tests
366367
void defaultImplicitCtorEnum(Baz arg = Bar::Item1);
368+
void defaultImplicitCtorEnumTwo(Bar arg = Bar::Items::Item1);
367369
void defaultIntWithLongExpression(unsigned int i = DEFAULT_INT);
368370
void defaultRefTypeEnumImplicitCtor(const QColor &fillColor = Qt::white);
369371
void rotate4x4Matrix(float angle, float x, float y, float z = 0.0f);

0 commit comments

Comments
 (0)