Skip to content

Warnings reported after comparing with object == or != #27928

@cston

Description

@cston

Warnings are reported for the second and third cases:

class C
{
    static void F(object? x, object y)
    {
        if (x != null) x.ToString();
        if ((object)x != null) x.ToString(); // warning
        if (x == y) x.ToString();            // warning
    }
}

[jcouv update:] Besides object equality, we should also consider other types (using attribute annotations).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions