Proposal: Implicit Generic Parameters ✨ #8366
Unanswered
fydar
asked this question in
Language Ideas
Replies: 1 comment
-
See: #1349 |
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.
-
Brief
Motivation
Take the following API.
Now if we have a generic method that utilises this API, it might look like the following:
When using
UseFactory<IntegerFactory, int>();
you have to supplyint
every time, regardless of it being the only valid generic option.Solution 1
This proposal seeks to add Implicit Generic Parameters.
Resolving Ambiguity, Multiple Generic Types
When multiple implicit generic arguments are available, explicit generic types must be supplied to resolve the ambiguity; resulting in identical code to what might have been before.
Resolving Ambiguity, Inheritance and Multiple Generic Types
When a single interface implementation is available on the type supplied (despite it inheriting the interface implementation on the base type) then the ambiguity is resolved using that single generic type.
Beta Was this translation helpful? Give feedback.
All reactions