Skip to content

Incorrect cast-can-be-removed suggestion with lambdas and implicit operators. #72134

@CyrusNajmabadi

Description

@CyrusNajmabadi

From #71926

public class MyClass
{
    static void Main()
    {
        Foo f = (Action)(() => { }); // IDE0004: Cast is redundant.

    }
}

public class Foo
{
    public static implicit operator Foo(Action value)
    {
        return default!;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions