[fpc-pascal] Interface bug or some new feature
denisgolovan
denisgolovan at yandex.ru
Sun Jan 6 11:42:25 CET 2019
Hi all
I've been using 3.1.1 compiler for a long time and now I am trying to upgrade to 3.3.1 from trunk.
However, I am stuck with some new behavior when using classes + interfaces.
I've managed to reproduce it in a small example which follows.
Specifically 3.1.1 compiler compiles it and correctly prints "Double".
3.3.1 compiler refuses to compile it at all.
Please comment if it's a bug or a new breaking feature.
//==================================================================
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
type
IIntf1 = interface
procedure P(i:Integer);
end;
TClass1 = class(TInterfacedObject, IIntf1)
procedure P(i:Integer);
end;
IIntf2 = interface(IIntf1)
procedure P(f:Double);
end;
TClass2 = class(TClass1, IIntf2) // Error: No matching implementation for interface method "P(LongInt);" found
procedure P(f:Double);
end;
procedure TClass1.P(i:Integer);
begin
WriteLn('Integer');
end;
procedure TClass2.P(f:Double);
begin
WriteLn('Double');
end;
var v2:TClass2;
begin
v2:=TClass2.Create;
v2.P(0.0);
v2.Free;
end.
//===================================================================
--
Regards,
Denis Golovan
More information about the fpc-pascal
mailing list