Handle overloads with different element counts

This commit is contained in:
Stefanos A 2013-11-17 21:27:09 +01:00
parent c175a486fc
commit b652145977
2 changed files with 13 additions and 3 deletions

View file

@ -304,7 +304,7 @@ namespace Bind.Structures
else
{
var list = Delegates[d.Name];
var index = list.IndexOf(d);
var index = list.FindIndex(w => w.CompareTo(d) == 0);
if (index < 0)
{
// Function not defined - add it!

View file

@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
@ -244,8 +245,17 @@ namespace Bind.Structures
else
{
Function existing = list[index];
if ((existing.Parameters.HasUnsignedParameters && !unsignedFunctions.IsMatch(existing.Name) && unsignedFunctions.IsMatch(f.Name)) ||
(!existing.Parameters.HasUnsignedParameters && unsignedFunctions.IsMatch(existing.Name) && !unsignedFunctions.IsMatch(f.Name)))
bool replace = existing.Parameters.HasUnsignedParameters &&
!unsignedFunctions.IsMatch(existing.Name) && unsignedFunctions.IsMatch(f.Name);
replace |= !existing.Parameters.HasUnsignedParameters &&
unsignedFunctions.IsMatch(existing.Name) && !unsignedFunctions.IsMatch(f.Name);
replace |=
(from p_old in existing.Parameters
join p_new in f.Parameters on p_old.Name equals p_new.Name
where p_new.ElementCount == 0 && p_old.ElementCount != 0
select true)
.Count() != 0;
if (replace)
{
list[index] = f;
}