Wrong handling in visibility checks during specialization / after latest changes.
- Fpc 2575cbc4
- Lazarus d3f0f0ee869ce83b07db680129a05a1afe457dbd
program Project1;
{$mode objfpc}{$H+}
uses LazDebuggerTemplate, LazDebuggerIntf;
type
TWatchesSupplier = class(specialize TWatchesSupplierClassTemplate<TObject>, IDbgWatchesSupplierIntf)
protected
procedure DoFoo;
end;
{ TWatchesSupplier }
procedure TWatchesSupplier.DoFoo;
begin
if Monitor <> nil then;
end;
begin
end.After https://wiki.freepascal.org/User_Changes_Trunk#Visibilities_of_members_of_generic_specializations this fails.
But it even fails (possible in two different ways), if visibility is fixed.
B:\lazarus_main\components\lazdebuggers\lazdebuggerintf\lazdebuggertemplate.pas
generic TInternalDbgSupplierBase<
_BASE: TObject;
_SUPPLIER_INTF: IInternalDbgSupplierIntfType;
_MONITOR_INTF //: IInternalDbgMonitorIntfType
>
= class(_BASE)
strict private
FMonitor: _MONITOR_INTF;
private // <<<<<<<<<<<<<<<<<<<<<<<<<<<<< THIS LINE HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
procedure SetMonitor(AMonitor: _MONITOR_INTF);
protected
procedure DoNewMonitor; virtual;
procedure DoDestroy; // FPC can not compile "destructor Destroy; override;"
property Monitor: _MONITOR_INTF read FMonitor; /// <<<<<<<<<<<<<<<<<<<<<<<<<<<<< AND THIS ONE
end;This generic is specialized as base class of TWatchesSupplier.
With the above code SetMonitor can indeed no longer be found.
Changing "THIS LINE HERE" to
strict protectedshould fix it. Methods instrict protectedcan be seen by inherited classes.
Yet doing so, leads to new errors. Errors of which I have yet failed to make any sense at all.
- (1st error) Why does it ignore (in its base class) the
strict protected:procedure SetMonitor(AMonitor: _MONITOR_INTF);_MONITOR_INTF=IDbgWatchesSupplierIntf (2nd error)generic TWatchesSupplierClassTemplateonly uses the interfaceIDbgWatchesSupplierIntfwhich hasprocedure SetMonitor(AMonitor: _MONITOR_INTF);'_MONITOR_INTF=IDbgWatchesMonitorIntf` => Why does it look for the other?lazdebuggertemplate.pas(129,59) Error: No matching implementation for interface method "SetMonitor(IDbgWatchesMonitorIntf);" found lazdebuggertemplate.pas(152,58) Error: No matching implementation for interface method "SetMonitor(IDbgLocalsMonitorIntf);" found
protectedgives
- (1st error) So that is the same error as with
strict protected - At least the other unexplained error is gone
- (2nd error) See below.
project1.lpr(6,22) Error: No matching implementation for interface method "SetMonitor(IDbgWatchesMonitorIntf);" found project1.lpr(15,6) Error: Identifier not found "Monitor"
public
property Monitoris protected in the base class. (See "AND THIS ONE"project1.lpr(15,6) Error: Identifier not found "Monitor"
Changing "THIS LINE HERE" to any of the 3 visibilities above should afaik compile.
Edited by Martin