Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirm that we want to report hidden HDN_NullCheckIsProbablyAlwaysFalse diagnostics #29868

Closed
AlekseyTs opened this issue Sep 13, 2018 · 1 comment

Comments

@AlekseyTs
Copy link
Contributor

        [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)
                );
        }
@gafter
Copy link
Member

gafter commented Feb 21, 2019

At LDM today we confirmed that we are dropping these diagnostics.

@gafter gafter closed this as completed Feb 21, 2019
@gafter gafter self-assigned this Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants