Skip to content

Commit 0255eb7

Browse files
committed
Resolve overloads with typedef-ed mapped params
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
1 parent fe68d33 commit 0255eb7

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/Generator/Passes/CheckAmbiguousFunctions.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,17 @@ private bool CheckDefaultParametersForAmbiguity(Function function, Function over
8080
var i = 0;
8181
for (; i < commonParameters; ++i)
8282
{
83-
AST.Type funcType = functionParams[i].Type.GetMappedType(
83+
AST.Type funcOriginalType = functionParams[i].Type.Desugar();
84+
AST.Type funcType = funcOriginalType.GetMappedType(
8485
TypeMaps, Options.GeneratorKind);
85-
AST.Type overloadType = overloadParams[i].Type.GetMappedType(
86+
AST.Type overloadOriginalType = overloadParams[i].Type.Desugar();
87+
AST.Type overloadType = overloadOriginalType.GetMappedType(
8688
TypeMaps, Options.GeneratorKind);
8789

88-
if (!funcType.Equals(functionParams[i].Type.Desugar()))
90+
if (!funcType.Equals(funcOriginalType))
8991
functionMappedParams++;
9092

91-
if (!overloadType.Equals(overloadParams[i].Type.Desugar()))
93+
if (!overloadType.Equals(overloadOriginalType))
9294
overloadMappedParams++;
9395

9496
AST.Type funcPointee = funcType.GetFinalPointee() ?? funcType;

tests/CSharp/CSharp.Tests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void TestUncompilableCode()
8686
}
8787

8888
CSharp.CSharp.FunctionInsideInlineNamespace();
89+
CSharp.CSharp.TakeMappedEnum(TestFlag.Flag1);
8990
using (CSharpTemplates.SpecialiseReturnOnly())
9091
{
9192
}

tests/CSharp/CSharp.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,14 @@ const Foo*& takeReturnReferenceToPointer(const Foo*& foo)
18601860
return foo;
18611861
}
18621862

1863+
void takeMappedEnum(TestFlag value)
1864+
{
1865+
}
1866+
1867+
void takeMappedEnum(TestFlags value)
1868+
{
1869+
}
1870+
18631871
boolean_t takeTypemapTypedefParam(boolean_t b)
18641872
{
18651873
return b;
@@ -1931,4 +1939,4 @@ const unsigned StructWithEmbeddedArrayOfStructObjectAlignmentOffsets[2]
19311939
{
19321940
offsetof(StructWithEmbeddedArrayOfStructObjectAlignment, boolean),
19331941
offsetof(StructWithEmbeddedArrayOfStructObjectAlignment, embedded_struct),
1934-
};
1942+
};

tests/CSharp/CSharp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,9 @@ DLL_API char* takeConstCharRef(const char& c);
14421442
DLL_API const char*& takeConstCharStarRef(const char*& c);
14431443
DLL_API const void*& rValueReferenceToPointer(void*&& v);
14441444
DLL_API const Foo*& takeReturnReferenceToPointer(const Foo*& foo);
1445+
typedef QFlags<TestFlag> TestFlags;
1446+
DLL_API void takeMappedEnum(TestFlag value);
1447+
DLL_API void takeMappedEnum(TestFlags value);
14451448

14461449
struct {
14471450
struct {

0 commit comments

Comments
 (0)