Skip to content
Discussion options

You must be logged in to vote

The local isEven has a delegate_type, and type inference for Test(isEven) will infer from the type arguments of the local type Func<int, bool> to the type parameters of the target type Func<T, bool>: see spec.

However, the method group IsEven has a function_type rather than a delegate_type, and there is no type inference rule for inferring from the parameter types of a function_type to the type parameters of the target type.

(By contrast, type inference of the corresponding lambda expression Test((int x) => x % 2 == 0); succeeds not because of function_type of the lambda but because type inference has a specific rule for anonymous functions: see spec.)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@333fred
Comment options

Comment options

You must be logged in to vote
3 replies
@MorenoGentili
Comment options

@jnm2
Comment options

jnm2 Mar 29, 2022
Collaborator

@RikkiGibson
Comment options

Answer selected by 333fred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #5962 on March 28, 2022 19:36.