var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (12,34): warning CS8620: Argument of type 'Pair<object, object?>' cannot be used for parameter 'p' of type 'Pair<object?, object>' in 'void E.Deconstruct(Pair<object?, object>? p, out object x, out object? y)' due to differences in the nullability of reference types.
// (object? x, object? y) = p;
Diagnostic(ErrorCode.WRN_NullabilityMismatchInArgument, "p").WithArguments("Pair<object, object?>", "Pair<object?, object>", "p", "void E.Deconstruct(Pair<object?, object>? p, out object x, out object? y)").WithLocation(12, 34),
// (14,9): warning CS8602: Dereference of a possibly null reference.
internal static void Deconstruct(this A<object?, object> a, out object? x, out object y) => throw null!;
}
class Program
{
static void F(B b)
{
(object? x, object? y) = b; // 1
x.ToString(); // 2
y.ToString();
}
}";
var comp = CreateCompilation(source, options: WithNonNullTypesTrue());
comp.VerifyDiagnostics(
// (15,34): warning CS8620: Argument of type 'B' cannot be used for parameter 'a' of type 'A<object?, object>' in 'void E.Deconstruct(A<object?, object> a, out object? x, out object y)' due to differences in the nullability of reference types.
// (object? x, object? y) = b; // 1
Diagnostic(ErrorCode.WRN_NullabilityMismatchInArgument, "b").WithArguments("B", "A<object?, object>", "a", "void E.Deconstruct(A<object?, object> a, out object? x, out object y)").WithLocation(15, 34),
// (16,9): warning CS8602: Dereference of a possibly null reference.
var comp = CreateCompilationWithTasksExtensions(new[] { s_IAsyncEnumerable, source });
comp.VerifyDiagnostics(
// (21,40): warning CS8620: Argument of type 'Pair<object, object?>' cannot be used for parameter 'p' of type 'Pair<object?, object>' in 'void E.Deconstruct(Pair<object?, object> p, out object? x, out object y)' due to differences in the nullability of reference types.
// await foreach (var (x1, y1) in e) // 1
Diagnostic(ErrorCode.WRN_NullabilityMismatchInArgument, "e").WithArguments("Pair<object, object?>", "Pair<object?, object>", "p", "void E.Deconstruct(Pair<object?, object> p, out object? x, out object y)").WithLocation(21, 40),
// (23,13): warning CS8602: Dereference of a possibly null reference.
// (26,51): warning CS8620: Argument of type 'Pair<object, object?>' cannot be used for parameter 'p' of type 'Pair<object?, object>' in 'void E.Deconstruct(Pair<object?, object> p, out object? x, out object y)' due to differences in the nullability of reference types.
var comp = CreateCompilationWithTasksExtensions(source);
comp.VerifyDiagnostics(
// (25,40): warning CS8620: Argument of type 'Pair<object, object?>' cannot be used for parameter 'p' of type 'Pair<object?, object>' in 'void E.Deconstruct(Pair<object?, object> p, out object? x, out object y)' due to differences in the nullability of reference types.
// await foreach (var (x1, y1) in e) // 1
Diagnostic(ErrorCode.WRN_NullabilityMismatchInArgument, "e").WithArguments("Pair<object, object?>", "Pair<object?, object>", "p", "void E.Deconstruct(Pair<object?, object> p, out object? x, out object y)").WithLocation(25, 40),
// (27,13): warning CS8602: Dereference of a possibly null reference.
// (30,51): warning CS8620: Argument of type 'Pair<object, object?>' cannot be used for parameter 'p' of type 'Pair<object?, object>' in 'void E.Deconstruct(Pair<object?, object> p, out object? x, out object y)' due to differences in the nullability of reference types.