Would anyone expect this to fail? I don't

Would anyone expect this to fail? I don't

program Project1;

type
  TFoo = class
  private
    class var Intf: IInterface;
  public
    class constructor Create;
    class destructor Destroy;
  end;

class constructor TFoo.Create;
begin
  intf := TInterfacedObject.Create;
end;

class destructor TFoo.Destroy;
begin
  Assert(Assigned(intf));
end;

begin
end.

But obviously managed class vars are finalized before the class destructor runs. I found this when I tried to do something with elements in an interfaced list but the list was already nil.

Comments