Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize Non-Generic methods #815

Merged
merged 4 commits into from Dec 11, 2020

Conversation

windischb
Copy link
Contributor

@windischb windischb commented Dec 9, 2020

As mentioned in #814 Generic Methods will now be last in order.
Prevents invoking the Generic Method instead of the Non-Generic Method of same name, if the Generic Method is declared before.

fixes #814

@@ -60,6 +60,17 @@ private static MethodDescriptor[] Prioritize(MethodDescriptor[] descriptors)
{
static int CreateComparison(MethodDescriptor d1, MethodDescriptor d2)
{
// if its a generic method, put it on the end
if (d1.Method.IsGenericMethod)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not stable and could potentially create infinite loops with some sort algorithm. The idea being that (a, b) might then be compared again with (b, a) and both would return opposite values if a == b.

If think the test should be that if d1 is generic and not d2, then put it at the end.

Comment on lines 74 to 76
// put params versions to end, they can be tricky to match and can cause trouble / extra overhead
if (d1.HasParams)
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't then there the same problem with potentially infinite loops?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably. This is an issue I found while working on Array.Sort this week. Can you fix it too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off course, i just wanted to ask before

@sebastienros sebastienros merged commit c0da73b into sebastienros:dev Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic Method Invocation Problem
3 participants