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

Nullability aspect of type argument inference is not propagated through the subsequent operations, causing absence of expected nullable diagnostics #30946

Closed
AlekseyTs opened this issue Nov 3, 2018 · 0 comments

Comments

@AlekseyTs
Copy link
Contributor

        [Fact]
        public void Test3()
        {
            var source = @"
class Outer
{
    void M0(Outer x, Outer? y)
    {
        M1(x).M2(y);
        M1<Outer>(x).M2(y);
    }

    Other<T> M1<T>(T x) where T : object => throw null;
}

class Other<T> where T : object
{
    public void M2(T y) {}
}
";

            CreateCompilation(source, options: WithNonNullTypesTrue()).VerifyDiagnostics(
                // (7,25): warning CS8604: Possible null reference argument for parameter 'y' in 'void Other<Outer>.M2(Outer y)'.
                //         M1<Outer>(x).M2(y);
                Diagnostic(ErrorCode.WRN_NullReferenceArgument, "y").WithArguments("y", "void Other<Outer>.M2(Outer y)").WithLocation(7, 25)
                );
        }

Expect to get similar error for M1(x).M2(y);

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

2 participants