title: Accessing private fields from a Class Helper
body: <p>Given</p>
  
  <pre><code>type
    TMyClass = class
    private
      FPrivateInt : Integer;
    protected
      FProtectedInt : Integer;
    public
      FPublicInt : Integer;
    end;
  </code></pre>
  
  <p>in one unit and</p>
  
  <pre><code>type
    TMyHelper = class helper for TMyClass
      function Sum : Integer;
    end;
  [...]
  function TMyHelper.Sum: Integer;
  begin
    Result := 0;
    Result := Result + FPublicInt;
    Result := Result + FProtectedInt;
    Result := Result + FPrivateInt;  // &lt;- compiler error here
  end;
  </code></pre>
  
  <p>in another, the XE8 compiler reports error "E2003 undeclared identifier 'FPrivateInt'.  This is what I would intuitively have expected, given the restricted visibility of private members
  outside the unit where a class is declared, if I hadn't seen the example on p89/90 of Marco Cantu's Delphi 2007 Handbook of a class helper
  which accesses private fields of the "helped" class and also an unequivocal statement
  in the opening paragraph of the accepted answer to this q</p>
  
  <p><a href="https://stackoverflow.com/a/21622319/505088">Can I call static private class method with class helper?</a></p>
  
  <p>which seems to support it: "As is widely known, helpers do crack private visibility. So, private members are visible from a class helper. ..."</p>
  
  <p>So, why do I get the E2003 Undeclared Identifier error?  I am obviously missing something somewhere, in my understanding or code.  I get the same error using XE4 and XE6, btw, and XE4 pre-dates the SO answer I've referenced, which is from last year.</p>