Repository navigation
binding: do not stop overload resolution at the first ambiguous pair - #46
Merged
Merged
Conversation
MethodResolver compared each candidate with the best one so far and returned null as soon as two candidates were equally specific, even if a later candidate was more specific than both. For a string[] argument, string.Concat(arr) was reported as an ambiguous match: Concat(params object[]) and Concat(IEnumerable<string>) are equally specific for it, although Concat(params string[]) is better than both. Remember the ambiguity and continue, as System.DefaultBinder does. Unlike DefaultBinder, also check that the selected method is more specific than the candidates before it, which it may not have been compared with. As in C#, a call with no method better than all the others stays ambiguous.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MethodResolvercompared each candidate with the best one so far and reported an ambiguous match as soon as two candidates were equally specific, even if a later candidate was more specific than both. For example,string.Concat(arr)with astring[]argument failed withAmbiguous match found:Concat(params object[])andConcat(IEnumerable<string>)are equally specific for it, althoughConcat(params string[])is better than both.This PR remembers the ambiguity and continues, as
System.DefaultBinderdoes. That walk compares a candidate only with the best one at the time, so the selected method is also checked against the candidates before it. As in C#, a call with no method better than all the others stays ambiguous: withNoBest(object, string),NoBest(string, object), andNoBest(IComparable, string), the callNoBest("a", "b")is rejected (CS0121), although the last overload is better than the first one.