Skip to content

! should suppress conversion warnings #30376

@cston

Description

@cston
using System.Runtime.CompilerServices;
[module: NonNullTypes]
class A { }
class B<T> { }
class C
{
    static void F(B<A?> x, B<A> y, B<A>? z)
    {
        var a = new[] { x, y! }; // warning
        var w = z ?? x!; // warning
    }
}
(9,28): warning CS8619: Nullability of reference types in value of type 'B<A>'
    doesn't match target type 'B<A?>'.
(10,22): warning CS8619: Nullability of reference types in value of type 'B<A?>'
    doesn't match target type 'B<A>'.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions