diff --git a/src/Generator/Passes/ExpressionHelper.cs b/src/Generator/Passes/ExpressionHelper.cs index 7ecb5150..708e4eb8 100644 --- a/src/Generator/Passes/ExpressionHelper.cs +++ b/src/Generator/Passes/ExpressionHelper.cs @@ -19,7 +19,8 @@ namespace CppSharp.Internal private static readonly Regex regexDoubleColon = new Regex(@"\w+::", RegexOptions.Compiled); private static readonly Regex regexName = new Regex(@"(\w+)", RegexOptions.Compiled); - public static bool? PrintExpression(BindingContext context, Function function, Type type, ExpressionObsolete expression, bool allowDefaultLiteral, ref string result) + public static bool? PrintExpression(BindingContext context, Function function, Type type, + ExpressionObsolete expression, bool allowDefaultLiteral, ref string result) { var desugared = type.Desugar(); @@ -226,7 +227,7 @@ namespace CppSharp.Internal private static bool? CheckForDefaultConstruct(BindingContext context, Type desugared, ExpressionObsolete expression, ref string result) { - var type = desugared.GetFinalPointee() ?? desugared; + var type = (desugared.GetFinalPointee() ?? desugared).Desugar(); Class decl; if (!type.TryGetClass(out decl)) diff --git a/tests/CSharp/CSharp.Tests.cs b/tests/CSharp/CSharp.Tests.cs index 7d0de367..6c467db6 100644 --- a/tests/CSharp/CSharp.Tests.cs +++ b/tests/CSharp/CSharp.Tests.cs @@ -318,6 +318,7 @@ public unsafe class CSharpTests Assert.That(methodsWithDefaultValues.DefaultMappedToEnum(), Is.EqualTo(Flags.Flag3)); methodsWithDefaultValues.DefaultMappedToZeroEnum(); methodsWithDefaultValues.DefaultMappedToEnumAssignedWithCtor(); + methodsWithDefaultValues.DefaultTypedefMappedToEnumRefAssignedWithCtor(); methodsWithDefaultValues.DefaultZeroMappedToEnumAssignedWithCtor(); Assert.That(methodsWithDefaultValues.DefaultImplicitCtorInt().Priv, Is.EqualTo(0)); methodsWithDefaultValues.DefaultImplicitCtorChar(); diff --git a/tests/CSharp/CSharp.cpp b/tests/CSharp/CSharp.cpp index d4e2d1af..c1f4dff0 100644 --- a/tests/CSharp/CSharp.cpp +++ b/tests/CSharp/CSharp.cpp @@ -713,6 +713,10 @@ void MethodsWithDefaultValues::defaultMappedToEnumAssignedWithCtor(QFlags { } +void MethodsWithDefaultValues::defaultTypedefMappedToEnumRefAssignedWithCtor(const TypedefedFlags& qFlags) +{ +} + void MethodsWithDefaultValues::defaultZeroMappedToEnumAssignedWithCtor(DefaultZeroMappedToEnum defaultZeroMappedToEnum) { } diff --git a/tests/CSharp/CSharp.h b/tests/CSharp/CSharp.h index c1ee5f94..1cf6642e 100644 --- a/tests/CSharp/CSharp.h +++ b/tests/CSharp/CSharp.h @@ -452,6 +452,8 @@ public: QFlags defaultMappedToEnum(const QFlags& qFlags = Flags::Flag3); void defaultMappedToZeroEnum(QFlags qFlags = 0); void defaultMappedToEnumAssignedWithCtor(QFlags qFlags = QFlags()); + typedef QFlags TypedefedFlags; + void defaultTypedefMappedToEnumRefAssignedWithCtor(const TypedefedFlags& qFlags = TypedefedFlags()); void defaultZeroMappedToEnumAssignedWithCtor(DefaultZeroMappedToEnum defaultZeroMappedToEnum = DefaultZeroMappedToEnum()); Quux defaultImplicitCtorInt(Quux arg = 0); void defaultImplicitCtorChar(Quux arg = 'a'); diff --git a/tests/CSharp/CSharpTemplates.h b/tests/CSharp/CSharpTemplates.h index 715e89ad..78cd32c8 100644 --- a/tests/CSharp/CSharpTemplates.h +++ b/tests/CSharp/CSharpTemplates.h @@ -698,10 +698,11 @@ template class QFlags { typedef int Int; - typedef int (*Zero); + struct Private; + typedef int (Private::*Zero); public: QFlags(T t); - QFlags(Zero = 0); + QFlags(Zero = nullptr); operator Int(); private: int flag;