roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Consider `params` and default values when inferring unique method signature

Open jjonescz opened this issue 1 year ago • 11 comments

When inferring unique method signature (when inferring delegate type), this PR reuses overload resolution logic to filter out inapplicable methods - including rules around params modifier (it's checked on the least overridden member) and applicability of normal/expanded form (we prefer expanded form if possible since we have no arguments). Signatures of the remaining applicable methods are compared to get a unique signature if possible (later used to synthesize the delegate type). This comparison considers default parameter values, but not params - we instead use the overload resolution result to determine whether the signature should have params or not (depending on whether overload resolution says all the candidates are applicable in normal or expanded form - if we have both kinds, that's an error like if we had duplicate signatures).

Fixes https://github.com/dotnet/roslyn/issues/71333. Corresponding speclet update: https://github.com/dotnet/csharplang/pull/7834 Test plan: https://github.com/dotnet/roslyn/issues/62485

jjonescz avatar Dec 21 '23 12:12 jjonescz