-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[Proposal] method overloading with respect to generic type constraints #962
Comments
I think this is mostly a duplicate of #250, point 2. Though having the two overloads in the same class is not part of that issue, and I believe it would require CLR change. |
How would this scenario be disambiguated?
|
@mburbea your scenario could in no way be disambiguated, but my scenario could be. If it is ambiguous then it is ambiguous and if it is not it's not. Compare your scenario with the following using 'normal' methods, which would also cause compilation errors, which is totally acceptable
My scenario is more equivalent to something like this
|
Closing as a dup of #250. The specific scenario cited here would require a CLR change. |
I find it hard to create fluent builder classes for hierarchical classes. As an alternative I find it easy to write builder extension methods, Consider the following example
Now we can write fluent build statements for A
And we can write the same for B
Unfortunately, there is a problem. If we want to add yet another Init builder extension for a different class, say class C, then a compilation error is reported.
This could be solved if method overloading would respect the generic type constraints because really the two Init method are not Ambiguous.
The text was updated successfully, but these errors were encountered: