[Fact]
public void ConditionalBranching_IsConstantPattern_Null_AlreadyTestedAsNonNull()
{
// PROTOTYPE(NullableReferenceTypes): confirm that we want such hidden warnings
CSharpCompilation c = CreateCompilation(new[] { @"
class C
{
void Test(object? x)
{
if (x != null)
{
if (x is null) // hidden
{
x.ToString(); // warn
}
else
{
x.ToString();
}
}
}
}
", NonNullTypesTrue, NonNullTypesAttributesDefinition });
c.VerifyDiagnostics(
// (8,22): hidden CS8606: Result of the comparison is possibly always false.
// if (x is null) // hidden
Diagnostic(ErrorCode.HDN_NullCheckIsProbablyAlwaysFalse, "null").WithLocation(8, 22),
// (10,17): warning CS8602: Possible dereference of a null reference.
// x.ToString(); // warn
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "x").WithLocation(10, 17)
);
}