6.6.5 Final methods

The final method can be used on a virtual or dynamic (or overridden) method to indicate it can no longer be overridden.

Given the following declarations:

type  
  TParent = class  
    procedure Test; virtual;  
    procedure TestFinal; virtual; final;  
  end;  
 
  TChild1 = class(TParent)  
    procedure test; override; final;  
  end;

The following declarations will result in compiler errors:

  TChild2 = class(TChild1)  
    // Error: There is no method in an ancestor class to be overridden: "Test;"  
    procedure test; override;  
  end;  
 
  TChild3 = class(TParent)  
    procedure TestProcedure; override;  
    // Error: There is no method in an ancestor class to be overridden: "TestFinal;"  
    procedure TestFinal; override;  
  end;