E2252 Method '%s' with identical parameters already exists (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

A method with an identical signature already exists in the data type.


program Produce;

  type
    t0 = class
      procedure f0(a : integer); overload;
      procedure f0(a : integer); overload;
    end;

procedure T0.f0(a : integer);
begin
end;

begin
end.


The error is produced here because there are two overloaded declarations for the same procedure.


program Solve;

  type
    t0 = class
      procedure f0(a : integer); overload;
      procedure f0(a : char); overload;
    end;

procedure T0.f0(a : integer);
begin
end;

procedure T0.f0(a : char);
begin
end;

begin
end.


There are different approaches to resolving this error. One approach is to remove the redundant declaration of the procedure. Another approach, taken here, is to change the parameter type of the duplicate declarations so that it creates a unique version of the overloaded procedure.