Skip to content

Commit

Permalink
Address PR feedback (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Jul 20, 2018
1 parent ddda977 commit 661e4f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ public override BoundNode VisitIsPatternExpression(BoundIsPatternExpression node
/// `switch (x) ... case Point p:` // PROTOTYPE(NullableReferenceTypes): not yet handled
///
/// If the expression is trackable, we'll return with different null-states for that expression in the two conditional states.
/// If the patterns is a `var` pattern, we'll also have re-inferred the `var` type with nullability and
/// If the pattern is a `var` pattern, we'll also have re-inferred the `var` type with nullability and
/// updated the state for that declared local.
/// </summary>
private void VisitPattern(BoundExpression expression, TypeSymbolWithAnnotations expressionResultType, BoundPattern pattern)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12131,12 +12131,21 @@ void Test(object? x)
{
if (x is var c)
{
x.ToString(); // warn
c /*T:object?*/ .ToString(); // warn
x.ToString(); // warn 1
c /*T:object?*/ .ToString(); // warn 2
}
else
{
x.ToString(); // warn
x.ToString(); // warn 3
}

if (x is var _)
{
x.ToString(); // warn 4
}
else
{
x.ToString(); // warn 5
}
}
}
Expand All @@ -12145,14 +12154,20 @@ void Test(object? x)
c.VerifyTypes();
c.VerifyDiagnostics(
// (8,13): warning CS8602: Possible dereference of a null reference.
// x.ToString(); // warn
// x.ToString(); // warn 1
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "x").WithLocation(8, 13),
// (9,13): warning CS8602: Possible dereference of a null reference.
// c /*T:object?*/ .ToString(); // warn
// c /*T:object?*/ .ToString(); // warn 2
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "c").WithLocation(9, 13),
// (13,13): warning CS8602: Possible dereference of a null reference.
// x.ToString(); // warn
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "x").WithLocation(13, 13)
// x.ToString(); // warn 3
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "x").WithLocation(13, 13),
// (18,13): warning CS8602: Possible dereference of a null reference.
// x.ToString(); // warn 4
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "x").WithLocation(18, 13),
// (22,13): warning CS8602: Possible dereference of a null reference.
// x.ToString(); // warn 5
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "x").WithLocation(22, 13)
);
}

Expand Down

0 comments on commit 661e4f1

Please sign in to comment.