title: Why does C# compiler thinks this nullabale reference can be null?
body: <p>I have this code where the compiler says that <code>myObj</code> in <code>ValidateMyObj(myObj)</code> may be null.
  Since it <em>has</em> to be not-null for <code>string.IsNullOrEmpty</code> to return <code>false</code> and enter the condition, how can it consider it could be null?</p>
  <p>But most of all, how can it then consider that it cannot be null in <code>myObj.Exists</code>?</p>
  <pre><code>var myObj = myObjCol.FirstOrDefault(x =&gt; x.Member);
  if (!string.IsNullOrEmpty(myObj?.StrProp))
  {
      ValidateMyObj(myObj);
      if (ViewBag.IsValid)
          myObj.Exists = true;
  }
  </code></pre>
  <p><strong>Edit: Playing with explicit null-check</strong></p>
  <p>Simply adding the explicit null-check gives the same behaviour:</p>
  <pre><code>var myObj = myObjCol.FirstOrDefault(x =&gt; x.Member);
  if (myObj != null &amp;&amp; !string.IsNullOrEmpty(myObj?.StrProp))
  {
      ValidateMyObj(myObj);
      if (ViewBag.IsValid)
          myObj.Exists = true;
  }
  </code></pre>
  <p>this compiles to (according to the ILSpy decompiler when deactivating the decompilation of the <code>?</code> operator)</p>
  <pre><code>MyObjType myObj = myObjCol.FirstOrDefault(x =&gt; x.Member);
  if (myObj != null &amp;&amp; !string.IsNullOrEmpty((myObj != null) ? myObj.StrProp : null))
  {
      ValidateMyObj(myObj);
      if (ViewBag.IsValid)
          myObj.Exists = true;
  }
  </code></pre>
  <p>On the other hand, if I then remove the null-conditional operator, then the squiggly line disapears.</p>
  <pre><code>var myObj = myObjCol.FirstOrDefault(x =&gt; x.Member);
  if (myObj != null &amp;&amp; !string.IsNullOrEmpty(myObj.StrProp))
  {
      ValidateMyObj(myObj);
      if (ViewBag.IsValid)
          myObj.Exists = true;
  }
  </code></pre>
  <p>In fact, it also disapears if I remove the explicit check <em>and</em> the null-conditional operator nor does it give one on the argument passed to ÌsNullOrEmpty`:</p>
  <pre><code>var myObj = myObjCol.FirstOrDefault(x =&gt; x.Member);
  if (!string.IsNullOrEmpty(myObj.StrProp))
  {
      ValidateMyObj(myObj);
      if (ViewBag.IsValid)
          myObj.Exists = true;
  }
  </code></pre>