title: Why does this interface hard cast seem to work?
body: <p>A Delphi mantra I grew up with is:</p>
  <p><a href="https://stackoverflow.com/a/755089/2306907">&quot;You should never ever, hard type cast an interface.&quot;</a> This probably <a href="http://hallvards.blogspot.com/2005/01/interface-to-interface-casts.html" rel="nofollow noreferrer">wont work</a>.</p>
  <p>Now I have to decide to refactor the following code:</p>
  <pre><code>type
      IFoo = interface
      end;
  
      TIFoo = class(TInterfacedObject, IFoo)
      end;
  
      IFooList = interface
          function GetItem(I: Integer): IFoo;
          procedure AddItem(AItem: IFoo);
      end;
  
      TIFooList = class(TInterfaceList, IFooList)
      protected
          function GetItem(I: Integer): IFoo;
          procedure AddItem(AItem: IFoo);
      end;
  
  
  function TIFooList.GetItem(I: Integer): IFoo;
  begin
      Result := IFoo(Items[I]);    // &lt;----- ???
  end;
  
  procedure TIFooList.AddItem(AItem: IFoo);
  begin
      Add(AItem);
  end;
  </code></pre>
  <p>This interface hard cast has been running a bazillion times for years without ever causing problems. Why? Pure Chance? Or does exist an exception to the rule?</p>
  <p><strong>Edit:</strong>
  I should have added: In the code base all <code>IFoo</code> instances are implemented by <code>TIFoo</code>.</p>