mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 13:09:35 +02:00

* one default properties test * visibility of extended type's symbols * class constructors (I don't know currently whether they are supported or not, because Delphi XE does not bring the "class constructor not allowed" error, but an internal error is created; maybe I should file a bug about this, too) git-svn-id: branches/svenbarth/classhelpers@17098 -
52 lines
796 B
ObjectPascal
52 lines
796 B
ObjectPascal
{ a helper of a parent class hides methods in the child class if its also a
|
|
parent of the helper for the child class }
|
|
program tchlp90;
|
|
|
|
{$ifdef fpc}
|
|
{$mode delphi}
|
|
{$endif}
|
|
{$apptype console}
|
|
|
|
type
|
|
TFoo = class
|
|
function TestFoo: Integer;
|
|
end;
|
|
|
|
TBar = class(TFoo)
|
|
function TestFoo: Integer;
|
|
end;
|
|
|
|
TFooHelper = class helper for TFoo
|
|
function TestFoo: Integer;
|
|
end;
|
|
|
|
TBarHelper = class helper(TFooHelper) for TBar
|
|
end;
|
|
|
|
function TFoo.TestFoo: Integer;
|
|
begin
|
|
Result := 1;
|
|
end;
|
|
|
|
function TBar.TestFoo: Integer;
|
|
begin
|
|
Result := 4;
|
|
end;
|
|
|
|
function TFooHelper.TestFoo: Integer;
|
|
begin
|
|
Result := 2;
|
|
end;
|
|
|
|
var
|
|
b: TBar;
|
|
res: Integer;
|
|
begin
|
|
b := TBar.Create;
|
|
res := b.TestFoo;
|
|
Writeln('b.TestFoo: ', res);
|
|
if res <> 2 then
|
|
Halt(1);
|
|
Writeln('ok');
|
|
end.
|