"Implement abstract class" should add "where T : default" when a parameter is covariant in T? #62092
Labels
Area-IDE
Bug
help wanted
The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone
Version Used: Visual Studio 17.2.5 (VisualStudio.17.Release/17.2.5+32616.157 ; C# Tools 4.2.0-4.22281.5+8d3180e5f00d42f0f0295165f756f368f0cbfa44)
Steps to Reproduce:
C2
Expected Behavior:
The resulting code should compile.
Actual Behavior:
M1
is correctly implemented butM2
is not, as it is missingwhere T : default
and thus does not compile:A more realistic example for is using a
Func<T?>
as parameter.It took me a while to even understand what the issue was, since the compiler doesn't say anything about
where T : default
being something you can do in the resulting error messages. Perhaps the compiler could detect that there is an override that would work if it hadwhere T : default
and warn about that?The text was updated successfully, but these errors were encountered: