You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fact]
public void TupleTypeInference_06()
{
var source =
@"class C
{
static void F(object? x, object? y)
{
if (y != null)
{
((object? x, object? y), object? z) t = ((x, y), y);
t.Item1.Item1.ToString();
t.Item1.Item2.ToString();
t.Item2.ToString();
t.Item1.x.ToString();
t.Item1.y.ToString();
t.z.ToString();
}
}
}";
var comp = CreateCompilation(new[] { source, NonNullTypesTrue, NonNullTypesAttributesDefinition });
// PROTOTYPE(NullableReferenceTypes): Should not report warning for
// `t.Item1.Item2`, `t.Item2`, `t.Item1.y`, or `t.z`.
comp.VerifyDiagnostics(
// (8,13): warning CS8602: Possible dereference of a null reference.
// t.Item1.Item1.ToString();
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.Item1.Item1").WithLocation(8, 13),
// (9,13): warning CS8602: Possible dereference of a null reference.
// t.Item1.Item2.ToString();
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.Item1.Item2").WithLocation(9, 13),
// (10,13): warning CS8602: Possible dereference of a null reference.
// t.Item2.ToString();
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.Item2").WithLocation(10, 13),
// (11,13): warning CS8602: Possible dereference of a null reference.
// t.Item1.x.ToString();
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.Item1.x").WithLocation(11, 13),
// (12,13): warning CS8602: Possible dereference of a null reference.
// t.Item1.y.ToString();
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.Item1.y").WithLocation(12, 13),
// (13,13): warning CS8602: Possible dereference of a null reference.
// t.z.ToString();
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "t.z").WithLocation(13, 13));
}
Related to #29699 (should conversion warnings be reported on elements or the whole tuple?)
The text was updated successfully, but these errors were encountered:
Related to #29699 (should conversion warnings be reported on elements or the whole tuple?)
The text was updated successfully, but these errors were encountered: