<div dir="auto"><div class="gmail_quote" dir="auto"><div dir="ltr">Am So., 6. Jan. 2019, 11:42 hat denisgolovan <<a href="mailto:denisgolovan@yandex.ru">denisgolovan@yandex.ru</a>> geschrieben:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all<br>
<br>
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.<br>
However, I am stuck with some new behavior when using classes + interfaces.<br>
I've managed to reproduce it in a small example which follows. <br>
<br>
Specifically 3.1.1 compiler compiles it and correctly prints "Double". <br>
3.3.1 compiler refuses to compile it at all.<br>
Please comment if it's a bug or a new breaking feature.<br>
<br>
//==================================================================<br>
program project1;<br>
<br>
{$mode objfpc}{$H+}<br>
<br>
uses<br>
{$IFDEF UNIX}{$IFDEF UseCThreads}<br>
cthreads,<br>
{$ENDIF}{$ENDIF}<br>
Classes<br>
{ you can add units after this };<br>
<br>
type<br>
IIntf1 = interface<br>
procedure P(i:Integer);<br>
end;<br>
<br>
TClass1 = class(TInterfacedObject, IIntf1)<br>
procedure P(i:Integer);<br>
end;<br>
<br>
IIntf2 = interface(IIntf1)<br>
procedure P(f:Double);<br>
end;<br>
<br>
TClass2 = class(TClass1, IIntf2) // Error: No matching implementation for interface method "P(LongInt);" found<br>
procedure P(f:Double);<br>
end;<br>
<br>
procedure TClass1.P(i:Integer);<br>
begin<br>
WriteLn('Integer');<br>
end;<br>
<br>
procedure TClass2.P(f:Double);<br>
begin<br>
WriteLn('Double');<br>
end;<br>
<br>
var v2:TClass2;<br>
begin<br>
v2:=TClass2.Create;<br>
v2.P(0.0);<br>
v2.Free;<br>
end.<br></blockquote></div><div dir="auto"><br></div><div dir="auto">The default visibility for classes without $M+ is private. Thus TClass1.P is private. An interface implementation does not have access to private methods of a parent class. So you need to declare P as protected for this to work. </div><div dir="auto">Though to be fair in the specific example you gave I think that it should work as both are within the same unit. We'll need to check that... </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div class="gmail_quote" dir="auto"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"></blockquote></div></div>