E2264 Cannot have method resolutions for interface '%s' (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

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

An attempt has been made to use a method resolution clause for an interface named in an implements clause.


program Produce;
type
  I0 = interface
    procedure i0p0(a : char);
  end;

  T0 = class(TInterfacedObject, I0)
    procedure I0.i0p0 = proc0;
    function getter : I0;
    procedure proc0(a : char);
    property p0 : I0 read getter implements I0;
  end;

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

function T0.getter : I0;
begin
end;
end.


In this example, the method proc0 is mapped onto the interface procedure i0p0, but because the interface is mentioned in a implements clause, this renaming is not allowed.


program Solve;
type
  I0 = interface
    procedure i0p0(a : char);
  end;

  T0 = class(TInterfacedObject, I0)
    function getter : I0;
    procedure i0p0(a : char);
    property p0 : I0 read getter implements I0;
  end;

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

function T0.getter : I0;
begin
end;
end.


The solution for this error is to remove the offending "name resolution clause". One easy way to accomplish this is to name the procedure in the class to the same name as the interface method.