Skip to content

Remove unnecessary cast changes overload resolution  #52524

@CyrusNajmabadi

Description

@CyrusNajmabadi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions