Skip to content

Record constructor arguments should propagate nullability to properties #44763

@RikkiGibson

Description

@RikkiGibson

Version Used:
f36e10a

Steps to Reproduce:

#nullable enable
data class B(string? X, string? Y)
{
    static void M1(bool flag)
    {
        B b = new B(""hello"", null);
        if (flag)
        {
            b.X.ToString(); // shouldn't warn
            b.Y.ToString(); // 1
        }

        b = b with { Y = ""world"" };
        b.X.ToString(); // shouldn't warn
        b.Y.ToString();
    }
}

Expected Behavior:
Warning only on line // 1

Actual Behavior:
Warnings on line // 1 as well as // shouldn't warn lines

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Misc

Relationships

None yet

Development

No branches or pull requests

Issue actions