Back to Csharplang

C# Language Design Meeting for August 7, 2023

meetings/2023/LDM-2023-08-07.md

latest1.8 KB
Original Source

C# Language Design Meeting for August 7, 2023

Agenda

Quote of the Day

  • "I've never said I'm not a hypocrite"

Discussion

Improvements to method group natural types

https://github.com/dotnet/roslyn/issues/69222

The proposal is a possible improvement over the mechanism decided on July 24th, 2023, where the uniqueness of a method group that allows it to have a natural type is determined scope by scope rather than across all possible instance and extension methods.

In that proposal, an instance or extension method can still be considered to apply, even if it would later be rejected by subsequent checks. For instance, type arguments might not satisfy constraints:

c#
var x = new C().M<int>; // CS8917	The delegate type could not be inferred.

public class C
{
    public void M<T>() { }
    public void M<T>(object o) where T : class { }
}

The proposal is to move these checks earlier, removing failing candidates so another candidate can be unique.

This additional pruning would cause us to depend on more details: It would succeed in more scenarios but at the cost of being more vulnerable to changes in those details. However, we accepted those same tradeoffs in method invocation scenarios several versions ago during a round of overload resolution improvements. This seems equivalent.

The proposal would incur slight breaking changes. They seem fairly negligible, but we should give it time in preview to confirm that we are not missing scenarios.

Conclusion

Change is approved. It will not be in C# 12, as we need bake time in preview to confirm that breaks are acceptable.