Pure null tests should affect both branches #33526
Labels
Area-Compilers
New Language Feature - Nullable Reference Types
Nullable Reference Types
Resolution-Fixed
The bug has been fixed and/or the requested behavior has been implemented
Milestone
From LDM 2/20/2019 and 3/6/2019 (adjusted
{}
andderived is Base
):"Pure" tests should set the null-state of
x
in both branches:x == null
x != null
(Type)x == null
(Type)x != null
x is null
x?.F
x?[i]
x ?? y
bool [EqualsBehavior]MyEquals(object other)
Note: pure tests 1 through 5 (included) are implemented or verified in #33929
"Not pure" tests should only set the null-state of
x
in one branch:x is Y // where Y is not a base of X
x is Y y
x is Y _
x is C { Property = 3 }
TryGetValue([NotNullWhenTrue])
[NotNulllWhenFalse] string.IsNullOrEmpty(s)
derived is Base
x is { }
switch
expressions and statements should also use this notion of "pure test" (LDM 3/6/2019).When closing this issue, we should also close #33526 (and remove references to both issues from code)
The text was updated successfully, but these errors were encountered: