Skip to content

Report nullable warnings for user-defined conversions on tuple elements #29699

@cston

Description

@cston
[module: System.Runtime.CompilerServices.NonNullTypes]
class A
{
    public static implicit operator C(A a) => new C();
}
class B : A
{
}
class C
{
    static void F((B?, B) x, (B, B?) y)
    {
        (C, C?) c;
        c = x;
        c = y;
    }
}

Expected:

(14,13): warning CS8604: Possible null reference argument for parameter 'a'
    in 'A.implicit operator C(A a)'
(15,13): warning CS8604: Possible null reference argument for parameter 'a'
    in 'A.implicit operator C(A a)'

Actual:

(14,13): warning CS8619: Nullability of reference types in value of type '(B?, B)'
    doesn't match target type '(C, C?)'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions