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).