[Lazarus] Code completion: Error: ancestor has same name as class.

Marcos Douglas md at delfire.net
Sun Mar 6 03:00:22 CET 2011


On Sat, Mar 5, 2011 at 10:57 PM, Marcos Douglas <md at delfire.net> wrote:
> The program below compiles. But if I try to use code completion here
> writeln(s.F...
> Occurs this error:
> test.lpr(8,31) Error: ancestor has same name as class.
>
> program test;
>
> {$mode objfpc}{$H+}
>
> uses SysUtils, Classes;
>
> type
>  TStringList = class(Classes.TStringList)
>  public
>    function Foo: string;
>  end;
>
> function TStringList.Foo: string;
> begin
>  result := 'Foo';
> end;
>
> var
>  s: TStringList;
> begin
>  s := TStringList.Create;
>  writeln(s.Foo);
>  s.Free;
>  readln;
> end.

Like that:
type
  TMyStringList = Classes.TStringList;
  TStringList = class(TMyStringList)
  public
    function Foo: string;
  end;

...works fine.


Marcos Douglas




More information about the Lazarus mailing list