summaryrefslogtreecommitdiff
path: root/fpcsrc/tests/webtbs/tw9306b.pp
blob: 37494a053f44c9151d236a04abd06c688e2af3f8 (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
52
53
54
55
56
57
58
59
60
61
62
63
{$mode delphi}

type
  IIntf = interface
    function Foo(const S: string): string;
  end;

  IIntf2 = interface(IIntf)
    function Foo(const S: string): Integer;
  end;

  TIntf = class(TInterfacedObject, IIntf)
  protected
    { IIntf }
    function Foo(const S: string): string;
  end;

  TIntf2 = class(TIntf, IIntf2)
  public
    { IIntf2 }
    function Foo(const S: string): Integer; overload;
  end;

var
  erridx : longint;

{ TIntf }

function TIntf.Foo(const S: string): string;
begin
  writeln('TIntf.Foo: ',S);
  if erridx=0 then
    erridx:=1;
  result:=S;
end;

{ TIntf2 }

function TIntf2.Foo(const S: string): Integer;
begin
  writeln('TIntf2.Foo: ',S);
  if erridx=1 then
    erridx:=2;
  result:=0;
end;

var
  i1 : IIntf;
  i2 : IIntf2;
begin
  erridx:=0;

  i1:=TIntf2.Create;
  i1.Foo('1234');

  i2:=TIntf2.Create;
  i2.Foo('1234');
  if erridx<>2 then
    begin
      writeln('Error');
      halt(1);
    end;
end.