private bool CheckDefaultParametersForAmbiguity(Function function, Function overload) { List <Parameter> functionParams = RemoveOperatorParams(function); List <Parameter> overloadParams = RemoveOperatorParams(overload); var commonParameters = Math.Min(functionParams.Count, overloadParams.Count); var i = 0; for (; i < commonParameters; ++i) { AST.Type funcType = functionParams[i].Type.GetMappedType( TypeMaps, Options.GeneratorKind); AST.Type overloadType = overloadParams[i].Type.GetMappedType( TypeMaps, Options.GeneratorKind); AST.Type funcPointee = funcType.GetFinalPointee() ?? funcType; AST.Type overloadPointee = overloadType.GetFinalPointee() ?? overloadType; if (((funcPointee.IsPrimitiveType() || overloadPointee.IsPrimitiveType()) && !funcType.Equals(overloadType)) || !funcPointee.Equals(overloadPointee)) { return(false); } } for (; i < functionParams.Count; ++i) { var funcParam = functionParams[i]; if (!funcParam.HasDefaultValue) { return(false); } } for (; i < overloadParams.Count; ++i) { var overloadParam = overloadParams[i]; if (!overloadParam.HasDefaultValue) { return(false); } } if (functionParams.Count > overloadParams.Count) { overload.ExplicitlyIgnore(); } else { function.ExplicitlyIgnore(); } return(true); }
private bool CheckDefaultParametersForAmbiguity(Function function, Function overload) { var commonParameters = Math.Min(function.Parameters.Count, overload.Parameters.Count); var i = 0; for (; i < commonParameters; ++i) { AST.Type funcType = GetFinalType(function.Parameters[i]); AST.Type overloadType = GetFinalType(overload.Parameters[i]); AST.Type funcPointee = funcType.GetFinalPointee() ?? funcType; AST.Type overloadPointee = overloadType.GetFinalPointee() ?? overloadType; if (((funcPointee.IsPrimitiveType() || overloadPointee.IsPrimitiveType()) && !funcType.Equals(overloadType)) || !funcPointee.Equals(overloadPointee)) { return(false); } } for (; i < function.Parameters.Count; ++i) { var funcParam = function.Parameters[i]; if (!funcParam.HasDefaultValue) { return(false); } } for (; i < overload.Parameters.Count; ++i) { var overloadParam = overload.Parameters[i]; if (!overloadParam.HasDefaultValue) { return(false); } } if (function.Parameters.Count > overload.Parameters.Count) { overload.ExplicitlyIgnore(); } else { function.ExplicitlyIgnore(); } return(true); }