Delphi Error – E2267 Previous declaration of ‘%s’ was not marked with the ‘overload’ directive

Delphi Compiler Error

E2267 Previous declaration of ‘%s’ was not marked with the ‘overload’ directive

Reason for the Error & Solution

There are two solutions to this problem. You can either remove the attempt at overloading or you can mark the original declaration with the overload directive. The example shown here marks the original declaration.

program Produce;
type
  Base = class
    procedure func(a : integer);
    procedure func(a : char); overload;
  end;

  procedure Base.func(a : integer);
  begin
  end;

  procedure Base.func(a : char);
  begin
  end;

end.

This example attempts to overload the char version of func without marking the first version of func as overloadable.

You must mark all functions to be overloaded with the overload directive. If overload were not required on all versions it would be possible to introduce a new method which overloads an existing method and then a simple recompilation of the source could produce different behavior.

program Solve;
type
  Base = class
    procedure func(a : integer); overload;
    procedure func(a : char); overload;
  end;

  procedure Base.func(a : integer);
  begin
  end;

  procedure Base.func(a : char);
  begin
  end;

end.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

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...