-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
The overload resolution rules have been updated in nearly every C# language update to improve the experience for programmers, making ambiguous invocations select the "obvious" choice. This has to be done carefully to preserve backward compatibility, but since we are usually resolving what would otherwise be error cases, these enhancements usually work out nicely.
There are three cases we might consider improving in C# 7:
- When a method group contains both instance and static members, we discard the instance members if invoked without an instance receiver or context, and discard the static members if invoked with an instance receiver. When there is no receiver, we include only static members in a static context, otherwise both static and instance members. When the receiver is ambiguously an instance or type due to a color-color situation, we include both.
- When a method group contains some generic methods whose type parameters do not satisfy their constraints, these members are removed from the candidate set.
- For a method group conversion, candidate methods whose return type doesn't match up with the delegate's return type are removed from the set.
There are probably additional improvements we could consider.
Reactions are currently unavailable