blob: 3f2197c18742bc5c9c9b3c96c0c7b2eaf89f56c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
{ a method defined in a parent helper has higher priority than a method defined
in the parent of the extended class - test 1}
program tchlp47;
{$ifdef fpc}
{$mode delphi}
{$endif}
{$apptype console}
type
TTest = class
function Test: Integer;
end;
TTestSub = class(TTest)
end;
TTestSubHelper = class helper for TTestSub
function Test: Integer;
end;
TTestSubHelperSub = class helper(TTestSubHelper) for TTestSub
function AccessTest: Integer;
end;
function TTest.Test: Integer;
begin
Result := 1;
end;
function TTestSubHelper.Test: Integer;
begin
Result := 2;
end;
function TTestSubHelperSub.AccessTest: Integer;
begin
Result := Test;
end;
var
t: TTestSub;
res: Integer;
begin
t := TTestSub.Create;
res := t.AccessTest;
Writeln('t.AccessTest: ', res);
if res <> 2 then
Halt(1);
Writeln('ok');
end.
|