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

Implement nullability analysis in LINQ queries #29863

Open
jcouv opened this issue Sep 13, 2018 · 0 comments
Open

Implement nullability analysis in LINQ queries #29863

jcouv opened this issue Sep 13, 2018 · 0 comments

Comments

@jcouv
Copy link
Member

jcouv commented Sep 13, 2018

One scenario in particular should work: from item in list where item is not null should result in a collection of not-null items. Reported a few times (including here).

Look for references to this issue in the code, such as NullableWalker.VisitQueryClause

Also replaced some PROTOTYPE markers with a reference to this issue:

        // https://github.com/dotnet/roslyn/issues/29863 Record in the node whether type
        // arguments were implicit, to allow for cases where the syntax is not an
        // invocation (such as a synthesized call from a query interpretation).
        private static bool HasImplicitTypeArguments(BoundExpression node)
        {
            var syntax = node.Syntax;
            if (syntax.Kind() != SyntaxKind.InvocationExpression)
            {
                // Unexpected syntax kind.
                return false;
            }
            var nameSyntax = Binder.GetNameSyntax(((InvocationExpressionSyntax)syntax).Expression, out var _);
            if (nameSyntax == null)
            {
                // Unexpected syntax kind.
                return false;
            }
            nameSyntax = nameSyntax.GetUnqualifiedName();
            return nameSyntax.Kind() != SyntaxKind.GenericName;
        }


        public override BoundNode VisitRangeVariable(BoundRangeVariable node)
        {
            var result = base.VisitRangeVariable(node);
            SetResult(node); // PROTOTYPE(NullableReferenceTypes)
            return result;
        }

This was also reported here.

@jcouv jcouv added this to the 16.0 milestone Sep 13, 2018
@jcouv jcouv changed the title Track inferred nullability in LINQ queries Implement nullability analysis in LINQ queries Sep 13, 2018
@jaredpar jaredpar added the Bug label Sep 14, 2018
@gafter gafter modified the milestones: 16.0, 16.1 Feb 26, 2019
@jcouv jcouv self-assigned this Mar 25, 2019
@jcouv jcouv added 4 - In Review A fix for the issue is submitted for review. 3 - Working and removed 4 - In Review A fix for the issue is submitted for review. labels Mar 25, 2019
@jcouv jcouv modified the milestones: 16.1, 16.2 Apr 23, 2019
@jcouv jcouv modified the milestones: 16.2, 16.3 Jun 19, 2019
@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 15, 2019
@jcouv jcouv modified the milestones: Compiler.Next, Compiler.Net5 Jan 6, 2020
@jaredpar jaredpar modified the milestones: Compiler.Net5, 16.8 Jun 23, 2020
@jcouv jcouv removed the 3 - Working label Jul 1, 2020
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