Skip to content

Nullability analysis skips initializer on dynamic receiver #81953

@jcouv

Description

@jcouv
#nullable enable
class C
{
    public dynamic D = null!;
    static void M()
    {
        var c = new C
        {
            D =
            {
                [0] = M3(null), // missing
                [M2(null)] = 0 // Cannot convert null literal to non-nullable reference type.
            }
        };
    }

    static int M2(object o) => 0;
    static int M3(object o) => 0;
}

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions