[Proposal]: Type inference using method group natural type #9006
Unanswered
jcouv
asked this question in
Language Ideas
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Type inference using method group natural type
Champion issue: #9007
Summary
It allows the natural type of a method group to contribute to method type inference
Context on method type inference
The current type inference rules allow
Ui
type parameters inC<U1 ... Uk>
when given aC<V1...Vk>
andC
is a class, struct, interface or delegate type.But they don't allow method groups to contribute to bounds.
Type inference
We modify the explicit parameter type inference rules to not just apply to explicitly-typed lambdas, but also to method groups:
An explicit parameter type inference is made from an expression
E
to a typeT
in the following way:E
is an explicitly typed anonymous function *or method group with a unique signature with parameter typesU₁...Uᵥ
andT
is a delegate type or expression tree type with parameter typesV₁...Vᵥ
then for eachUᵢ
an exact inference is made fromUᵢ
to the correspondingVᵢ
.Follow-ups:
Relates to issue for method groups contributing to method type inference: #129
LDM Discussions
Beta Was this translation helpful? Give feedback.
All reactions