mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 05:48:50 +02:00

o "unique" class (and interface) type aliases should actually not exist at all except for overload resolution. All the rest (VMT, UUID, RTTI, ...) should be taken from the aliased class/interface o there is one Delphi-incompatibily left after this change, but it shouldn't matter: tw8180 does not compile if you change the declaration to "tcl=class(TInterfacedObject,XStr,iinterface)", while Kylix does compile that. It doesn't really matter though, because in Kylix this actually adds iinterface twice as implemented interface, so there is no point in accepting this. git-svn-id: trunk@46773 -
76 lines
1.1 KiB
ObjectPascal
76 lines
1.1 KiB
ObjectPascal
program Project1;
|
|
{$Mode objfpc}
|
|
|
|
type
|
|
TFoo = class
|
|
constructor create; virtual;
|
|
end;
|
|
|
|
TBar = type TFoo;
|
|
|
|
TBaz = class(TBar)
|
|
constructor create; override;
|
|
end;
|
|
|
|
constructor TFoo.create;
|
|
begin
|
|
writeln('TFoo.create');
|
|
end;
|
|
|
|
constructor TBaz.create;
|
|
begin
|
|
inherited;
|
|
writeln('TBaz.create');
|
|
end;
|
|
|
|
var
|
|
test1tbar: boolean;
|
|
|
|
procedure test1(o: TFoo; error: longint); overload;
|
|
begin
|
|
writeln('test1 tfoo');
|
|
o.free;
|
|
if test1tbar then
|
|
halt(error);
|
|
end;
|
|
|
|
procedure test1(o: TBar; error: longint); overload;
|
|
begin
|
|
writeln('test1 tbar');
|
|
o.free;
|
|
if not test1tbar then
|
|
halt(error);
|
|
end;
|
|
|
|
var
|
|
b: tbar;
|
|
begin
|
|
if not tbar.inheritsfrom(tfoo) then
|
|
begin
|
|
writeln('error 1');
|
|
halt(1);
|
|
end;
|
|
if not tbaz.inheritsfrom(tbar) then
|
|
begin
|
|
writeln('error 2');
|
|
halt(2);
|
|
end;
|
|
if tbar.classname<>'TFoo' then
|
|
begin
|
|
writeln('error 3');
|
|
halt(3);
|
|
end;
|
|
if tfoo.classname<>'TFoo' then
|
|
begin
|
|
writeln('error 4');
|
|
halt(4);
|
|
end;
|
|
TBaz.create.free;
|
|
test1tbar:=false;
|
|
test1(tfoo.create,5);
|
|
test1(tbar.create,6);
|
|
b:=tbar.create;
|
|
test1tbar:=true;
|
|
test1(b,7);
|
|
end.
|