HomeDelphiDelphi Error – H2365 Override method %s.%s should match case of ancestor %s.%s

Delphi Error – H2365 Override method %s.%s should match case of ancestor %s.%s

Delphi Compiler Error

H2365 Override method %s.%s should match case of ancestor %s.%s

Reason for the Error & Solution

When overriding a method, the best practice is to match the case of the ancestor method. This prevents any downstream failure that would not be anticipated by a Delphi user, who expects case-insensitivity.

Example

Hint H2365 is emitted in the following case:

type
  TClass1 = class
    procedure VirtualMethod; virtual; abstract;
  end;
 
  TClass2 = class(TClass1)
    procedure virtualmethod; override; 
  end;
 
procedure TClass2.virtualmethod;
begin
end;

Here are some situations in which Delphi is case-sensitive:

In unit declarations and uses clauses, unit names must match the file names in case. In other contexts (such as qualified identifiers), unit names are case insensitive. To avoid problems with unit references, refer to the unit source file explicitly:
uses MyUnit in "myunit.pas";
  • Registering components
When you write your own components and you want to register them, the register function that you declare must be written like this:
procedure Register;  <<-- Leading capital required.  
The name of the Register procedure is case-sensitive for design-time packages. If you declare a register procedure (lower-case), and even if hint H2365 is not emitted, you do not get the expected result; your component does not get registered. For more information, see .
  • Importing external functions
When importing external functions, the exact case used in the DLL must be preserved.

Share:

Leave a Reply

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...