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

entry/exit (mantis #10897) * fixed tinterface2 which crashed after this change. It also crashed under Kylix: you cannot assign the result of an interfaced class to a class instance variable and then use it both as an interface (refcounted) and as class (non-refcounted) git-svn-id: trunk@10405 -
51 lines
623 B
ObjectPascal
51 lines
623 B
ObjectPascal
{ %VERSION=1.1 }
|
|
|
|
{$ifdef fpc}
|
|
{$mode objfpc}
|
|
{$endif}
|
|
|
|
type
|
|
ITest = interface(IUnknown)
|
|
procedure DoSomething;
|
|
end;
|
|
|
|
|
|
TMyClass = class(TInterfacedObject, ITest)
|
|
procedure DoSomething;
|
|
end;
|
|
|
|
var
|
|
i : longint;
|
|
|
|
procedure TMyClass.DoSomething;
|
|
begin
|
|
inc(i);
|
|
end;
|
|
|
|
|
|
procedure DoTest(const ATest: ITest);
|
|
begin
|
|
ATest.DoSomething;
|
|
end;
|
|
|
|
|
|
procedure DoTest2(ATest: ITest);
|
|
begin
|
|
ATest.DoSomething;
|
|
end;
|
|
|
|
|
|
var
|
|
c: ITest;
|
|
begin
|
|
i:=0;
|
|
c := TMyClass.Create;
|
|
DoTest(c);
|
|
DoTest2(c);
|
|
if i<>2 then
|
|
begin
|
|
writeln('Problem with passing interfaces as parameters');
|
|
halt(1);
|
|
end;
|
|
end.
|