[fpc-pascal] Interface bug or some new feature

Jonas Maebe jonas at freepascal.org
Sun Jan 6 14:07:21 CET 2019


On 06/01/19 14:00, Sven Barth via fpc-pascal wrote:
> Am 06.01.2019 um 12:56 schrieb Jonas Maebe:
>> On 06/01/19 11:42, denisgolovan wrote:
>>
>>> 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.
>>
>> http://wiki.freepascal.org/User_Changes_Trunk#Methods_implementing_interface_methods_and_overloads 
>>
> 
> But shouldn't that specifc example work? TClass1.P is public here, not 
> private.

It's unrelated to public and private (that is covered in 
http://wiki.freepascal.org/User_Changes_Trunk#Visibility_of_methods_implementing_interface_methods 
). It's only about overloads. If you do not declare a method as 
"overload", the compiler will now stop searching the class hierarchy as 
soon as it finds a class that declares a method with the right name. It 
already did this when calling methods, now it also does it for interface 
method resolution.

> Also unlike FPC Delphi does not give the following warning: Warning: An 
> inherited method is hidden by "P(Double);"

At least Kylix fails to compile the test program:

Borland Delphi for Linux Version 14.5
Copyright (c) 1983,2002 Borland Software Corporation
tt.pp(31) Error: Declaration of 'P' differs from declaration in 
interface 'IIntf2'
tt.pp(49)


Jonas



More information about the fpc-pascal mailing list