22using System . Linq ;
33using CppSharp . AST ;
44using CppSharp . AST . Extensions ;
5+ using CppSharp . Types ;
56
67namespace CppSharp . Passes
78{
@@ -65,17 +66,17 @@ public override bool VisitFunctionDecl(AST.Function function)
6566 return true ;
6667 }
6768
68- private static bool CheckDefaultParametersForAmbiguity ( Function function , Function overload )
69+ private bool CheckDefaultParametersForAmbiguity ( Function function , Function overload )
6970 {
7071 var commonParameters = Math . Min ( function . Parameters . Count , overload . Parameters . Count ) ;
7172
7273 var i = 0 ;
7374 for ( ; i < commonParameters ; ++ i )
7475 {
75- var funcParam = function . Parameters [ i ] ;
76- var overloadParam = overload . Parameters [ i ] ;
76+ AST . Type funcType = GetFinalType ( function . Parameters [ i ] ) ;
77+ AST . Type overloadType = GetFinalType ( overload . Parameters [ i ] ) ;
7778
78- if ( ! funcParam . QualifiedType . Equals ( overloadParam . QualifiedType ) )
79+ if ( ! funcType . Equals ( overloadType ) )
7980 return false ;
8081 }
8182
@@ -101,6 +102,30 @@ private static bool CheckDefaultParametersForAmbiguity(Function function, Functi
101102 return true ;
102103 }
103104
105+ private AST . Type GetFinalType ( Parameter parameter )
106+ {
107+ TypeMap typeMap ;
108+ if ( Context . TypeMaps . FindTypeMap ( parameter . Type , out typeMap ) )
109+ {
110+ var typePrinterContext = new TypePrinterContext
111+ {
112+ Kind = TypePrinterContextKind . Managed ,
113+ Parameter = parameter ,
114+ Type = typeMap . Type
115+ } ;
116+
117+ switch ( Options . GeneratorKind )
118+ {
119+ case Generators . GeneratorKind . CLI :
120+ return typeMap . CLISignatureType ( typePrinterContext ) . Desugar ( ) ;
121+ case Generators . GeneratorKind . CSharp :
122+ return typeMap . CSharpSignatureType ( typePrinterContext ) . Desugar ( ) ;
123+ }
124+ }
125+
126+ return parameter . Type . Desugar ( ) ;
127+ }
128+
104129 private static bool CheckConstnessForAmbiguity ( Function function , Function overload )
105130 {
106131 var method1 = function as Method ;
0 commit comments