@@ -54,7 +54,7 @@ public override bool VisitFunctionDecl(AST.Function function)
5454
5555 if ( CheckConstnessForAmbiguity ( function , overload ) ||
5656 CheckDefaultParametersForAmbiguity ( function , overload ) ||
57- CheckSingleParameterPointerConstnessForAmbiguity ( function , overload ) )
57+ CheckParametersPointerConstnessForAmbiguity ( function , overload ) )
5858 {
5959 function . IsAmbiguous = true ;
6060 overload . IsAmbiguous = true ;
@@ -186,67 +186,57 @@ private static bool CheckConstnessForAmbiguity(Function function, Function overl
186186 return false ;
187187 }
188188
189- private static bool CheckSingleParameterPointerConstnessForAmbiguity (
189+ private static bool CheckParametersPointerConstnessForAmbiguity (
190190 Function function , Function overload )
191191 {
192192 var functionParams = function . Parameters . Where (
193193 p => p . Kind == ParameterKind . Regular ) . ToList ( ) ;
194194
195- // It's difficult to handle this case for more than one parameter.
196- // For example, if we have:
197- //
198- // void f(float&, const int&);
199- // void f(const float&, int&);
200- //
201- // What should we do? Generate both? Generate the first one encountered?
202- // Generate the one with the least amount of "complex" parameters?
203- // So let's just start with the simplest case for the time being.
204-
205- if ( functionParams . Count != 1 )
206- return false ;
207-
208195 var overloadParams = overload . Parameters . Where (
209196 p => p . Kind == ParameterKind . Regular ) . ToList ( ) ;
210197
211- if ( overloadParams . Count != 1 )
198+ if ( functionParams . Count != overloadParams . Count )
212199 return false ;
213200
214- var parameterFunction = functionParams [ 0 ] ;
215- var parameterOverload = overloadParams [ 0 ] ;
201+ for ( int i = 0 ; i < functionParams . Count ; i ++ )
202+ {
203+ var parameterFunction = functionParams [ i ] ;
204+ var parameterOverload = overloadParams [ i ] ;
216205
217- var pointerParamFunction = parameterFunction . Type . Desugar ( ) as PointerType ;
218- var pointerParamOverload = parameterOverload . Type . Desugar ( ) as PointerType ;
206+ var pointerParamFunction = parameterFunction . Type . Desugar ( ) as PointerType ;
207+ var pointerParamOverload = parameterOverload . Type . Desugar ( ) as PointerType ;
219208
220- if ( pointerParamFunction == null || pointerParamOverload == null )
221- return false ;
209+ if ( pointerParamFunction == null || pointerParamOverload == null )
210+ continue ;
222211
223- if ( ! pointerParamFunction . GetPointee ( ) . Equals ( pointerParamOverload . GetPointee ( ) ) )
224- return false ;
212+ if ( ! pointerParamFunction . GetPointee ( ) . Equals ( pointerParamOverload . GetPointee ( ) ) )
213+ continue ;
225214
226- if ( parameterFunction . IsConst && ! parameterOverload . IsConst )
227- {
228- function . ExplicitlyIgnore ( ) ;
229- return true ;
230- }
215+ if ( parameterFunction . IsConst && ! parameterOverload . IsConst )
216+ {
217+ function . ExplicitlyIgnore ( ) ;
218+ return true ;
219+ }
231220
232- if ( parameterOverload . IsConst && ! parameterFunction . IsConst )
233- {
234- overload . ExplicitlyIgnore ( ) ;
235- return true ;
236- }
221+ if ( parameterOverload . IsConst && ! parameterFunction . IsConst )
222+ {
223+ overload . ExplicitlyIgnore ( ) ;
224+ return true ;
225+ }
237226
238- if ( pointerParamFunction . Modifier == PointerType . TypeModifier . RVReference &&
239- pointerParamOverload . Modifier != PointerType . TypeModifier . RVReference )
240- {
241- function . ExplicitlyIgnore ( ) ;
242- return true ;
243- }
227+ if ( pointerParamFunction . Modifier == PointerType . TypeModifier . RVReference &&
228+ pointerParamOverload . Modifier != PointerType . TypeModifier . RVReference )
229+ {
230+ function . ExplicitlyIgnore ( ) ;
231+ return true ;
232+ }
244233
245- if ( pointerParamFunction . Modifier != PointerType . TypeModifier . RVReference &&
246- pointerParamOverload . Modifier == PointerType . TypeModifier . RVReference )
247- {
248- overload . ExplicitlyIgnore ( ) ;
249- return true ;
234+ if ( pointerParamFunction . Modifier != PointerType . TypeModifier . RVReference &&
235+ pointerParamOverload . Modifier == PointerType . TypeModifier . RVReference )
236+ {
237+ overload . ExplicitlyIgnore ( ) ;
238+ return true ;
239+ }
250240 }
251241
252242 return false ;
0 commit comments