C# compiler should report why a delegate conversion failed #24675
Labels
3 - Working
Area-Compilers
Concept-Diagnostic Clarity
The issues deals with the ease of understanding of errors and warnings.
Feature Request
Milestone
I was recently implementing support for dotnet/csharplang#98 and discovered a regression in the quality of diagnostic for the following situation
We used to report
It used to be that
Program.Method
was a perfectly good method group that converts to the delegate typeD
with an error. However, under the new proposed rules for dotnet/csharplang#98 it remains a perfectly good method group that no longer converts to the delegate typeD
, as no method in the group survives the new overload resolution rules. The compiler, under the new rules, reportsThe compiler has enough information internally to know why overload resolution failed here (it is because "An object reference is required for the non-static field, method, or property 'Program.Method()'"). However, the C# compiler currently never reports the underlying reason for a method group conversion failure.
I propose that some or all causes of a method group conversion failure should be reported. That would restore the quality of diagnostic for this particular case.
The text was updated successfully, but these errors were encountered: