title: Nullable references types and Local functions - Do they play well together?
body: <p>I was playing around with VS2019, tyring new C#-8 features on an existing code body.  I took a small project and proceeded to convert it to use the new nullable reference types feature.  In the process, I came across this case:</p>
  
  <pre><code>using System;
  
  #nullable enable
  
  namespace NullableRefTest
  {
    class Demo
    {
      public string? Property { get; set; }
  
      public int Test()
      {
        if (null == Property) // 1
          throw new InvalidOperationException();
  
        int f()
        {
          return Property.Length; // 2
        }
  
        return f(); 
      }
    }
  }
  </code></pre>
  
  <p>Compiling this with C#-8 enabled generates a CS8602 possible dereference of a null refrence warning on // 2.</p>
  
  <p>Now, I would maintain, that there is clearly no null reference possible here - the visibility and lifetime of f() is such that it cannot possibly be invoked before the null reference test at //1.</p>
  
  <p>I'm assuming that the warning arises because of how local functions are actually implemented by hoisting them to an anonymous class, and within that class considered out of context, this is indeed a possible null reference.</p>
  
  <p>Is this just a case that the compiler isn't getting right yet, or is there something more insidious here that says that this warning should remain?</p>