Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c051073

Browse files
committedJul 3, 2019
Prefer non-mapped types when resolving ambiguous overloads
This fixes a missing specialized method when it has a parameter with type a mapped template which is ignored when dependent. Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent e430f6f commit c051073

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
 

‎src/Generator/Passes/CheckAmbiguousFunctions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ private bool CheckDefaultParametersForAmbiguity(Function function, Function over
7575

7676
var commonParameters = Math.Min(functionParams.Count, overloadParams.Count);
7777

78+
int functionMappedParams = 0;
79+
int overloadMappedParams = 0;
80+
7881
var i = 0;
7982
for (; i < commonParameters; ++i)
8083
{
@@ -83,6 +86,11 @@ private bool CheckDefaultParametersForAmbiguity(Function function, Function over
8386
AST.Type overloadType = overloadParams[i].Type.GetMappedType(
8487
TypeMaps, Options.GeneratorKind);
8588

89+
if (!funcType.Equals(functionParams[i].Type.Desugar()))
90+
functionMappedParams++;
91+
if (!overloadType.Equals(overloadParams[i].Type.Desugar()))
92+
overloadMappedParams++;
93+
8694
AST.Type funcPointee = funcType.GetFinalPointee() ?? funcType;
8795
AST.Type overloadPointee = overloadType.GetFinalPointee() ?? overloadType;
8896

@@ -106,7 +114,8 @@ private bool CheckDefaultParametersForAmbiguity(Function function, Function over
106114
return false;
107115
}
108116

109-
if (functionParams.Count > overloadParams.Count)
117+
if (functionParams.Count > overloadParams.Count ||
118+
functionMappedParams < overloadMappedParams)
110119
overload.ExplicitlyIgnore();
111120
else
112121
function.ExplicitlyIgnore();

‎tests/CSharp/CSharp.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public override void CSharpMarshalToManaged(CSharpMarshalContext ctx)
149149
}
150150
}
151151

152+
public override bool IsIgnored => Type.IsDependent;
153+
152154
private static Type GetEnumType(Type mappedType)
153155
{
154156
var type = mappedType.Desugar();

‎tests/CSharp/CSharpTemplates.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,17 +706,17 @@ template <typename T>
706706
class HasCtorWithMappedToEnum
707707
{
708708
public:
709-
HasCtorWithMappedToEnum(QFlags<T> t);
710709
HasCtorWithMappedToEnum(T t);
710+
HasCtorWithMappedToEnum(QFlags<T> t);
711711
};
712712

713713
template <typename T>
714-
HasCtorWithMappedToEnum<T>::HasCtorWithMappedToEnum(QFlags<T> t)
714+
HasCtorWithMappedToEnum<T>::HasCtorWithMappedToEnum(T t)
715715
{
716716
}
717717

718718
template <typename T>
719-
HasCtorWithMappedToEnum<T>::HasCtorWithMappedToEnum(T t)
719+
HasCtorWithMappedToEnum<T>::HasCtorWithMappedToEnum(QFlags<T> t)
720720
{
721721
}
722722

0 commit comments

Comments
 (0)
Please sign in to comment.