Re: new overloading model

Simon Pieters:
> OK, but doesn't this give two candidates?
>
> void add(HTMLOptionElement element, optional HTMLElement? before);
> void add(HTMLOptGroupElement element, optional HTMLElement? before);
> void add(HTMLOptionElement element, long before);
> void add(HTMLOptGroupElement element, long before);
>
> options.add(document.createElement('option'), null);

No, since you would consider nullable interface types to also be exactly 
matchable.  You'd start off with this set:

   { <add, (HTMLOptionElement)>,
     <add, (HTMLOptionElement, HTMLElement?)>,
     <add, (HTMLOptGroupElement)>,
     <add, (HTMLOptGroupElement, HTMLElement?)>,
     <add, (HTMLOptionElement, long)>,
     <add, (HTMLOptGroupElement, long)> }

then you'd remove the length-1 entries:

   { <add, (HTMLOptionElement, HTMLElement?)>,
     <add, (HTMLOptGroupElement, HTMLElement?)>,
     <add, (HTMLOptionElement, long)>,
     <add, (HTMLOptGroupElement, long)> }

then you would start on the loop per argument position and entry.  The 
two HTMLOptGroupElement entries would be disqualified because interface 
types are an exact match, and the value passed in is an 
HTMLOptionElement instead.  For the second argument, the JS null value 
does not exactly match the long types, so those would be disqualified 
too.  You should be left just with the (HTMLOptionElement, HTMLElement?) 
entry.

Received on Wednesday, 21 December 2011 08:17:50 UTC