Skip to content

[Proposal]: Type inference using method group natural type #9007

Description

@333fred

Type inference using method group natural type

Summary

It allows the natural type of a method group to contribute to method type inference, so scenarios like the following can work:

Test(IsEven); // Error CS0411	The type arguments for method 'Program.Test<T>(Func<T, bool>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

partial class Program
{
    public static bool IsEven(int x) => x % 2 == 0;
    public static void Test<T>(Func<T, bool> predicate) { }
}

Design meetings

Metadata

Metadata

Assignees

Type

No type

Projects

Status
Language/design

Relationships

None yet

Development

No branches or pull requests

Issue actions