Skip to content

Allow operator==(S, int) to be lifted #25318

@jcouv

Description

@jcouv

In PR #24913, I fixed the case where s doesn't have an operator== and I also verified the case where s has operator==(S, S).
But while working on tuple equality, I thought of this scenario and it doesn't seem to work.

struct MyType
{
    int i;
    public MyType(int value)
    {
        i = value;
    }
    static void Main()
    {
        MyType? x = null;

        _ = x == 0;
    }
    public static bool operator==(MyType x, int y)
        => x.i == y;
    public static bool operator!=(MyType x, int y)
        => !(x == y);
    public override bool Equals(object o) => throw null;
    public override int GetHashCode() => throw null;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions