Given a case like:
ValueTask<object?> v = new((object?)null);
Then "remove unnecessary cast" says that (object?) is unnecessary and can be removed. However, if you do this, overload resolution switches from calling the ValueTask(object?) constructor to teh ValueTask(Task<object?> task) constructor. First, we shouldn't offer this if necessary for overload resolution. Second, it's not quite clear to me why passing null here isn't ambiguous to the compiler as there seem to be too applicable overloads.
This woudl be fixed with #50043
Tagging @jaredpar for visibility on both issues. First, it would be really great if we could get eyes on #50043. Second, it seems very weird here that new(null) even compiles here.
Given a case like:
Then "remove unnecessary cast" says that
(object?)is unnecessary and can be removed. However, if you do this, overload resolution switches from calling theValueTask(object?)constructor to tehValueTask(Task<object?> task)constructor. First, we shouldn't offer this if necessary for overload resolution. Second, it's not quite clear to me why passingnullhere isn't ambiguous to the compiler as there seem to be too applicable overloads.This woudl be fixed with #50043
Tagging @jaredpar for visibility on both issues. First, it would be really great if we could get eyes on #50043. Second, it seems very weird here that
new(null)even compiles here.