Type inference in extension methods #6275
Unanswered
alex-bello
asked this question in
Q&A
Replies: 0 comments 1 reply
-
I don't think extension methods are or should be special here. Which means this should work if both #1349 and #741 were implemented. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to infer some of the type parameters in an extension method based on the type being extended? For example, let's say I have a builder class that has three types param with constraints.
I'd like to add an extension method that has a type parameter with a constraint as well that also relies on other type parameters with constraints. However, I'd like to avoid having to list the same type parameters over and over with each extension method that has a new type parameter.
I was hoping that I'd be able to just do the following:
However, the compiler does not recognize the extension method. Is there a way to make this possible?
Beta Was this translation helpful? Give feedback.
All reactions