Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-08

FPC missed method visibility issue

3 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Last night I ported a unit in fpGUI to VCL using Delphi 7. Delphi 7 reported a lot of warnings I never saw under FPC 2.2.3 or FPC 2.2.0

Here is one such example: Method visibility level

-------------[ tiBaseMediator.pas ]-----------------
  {$mode delphi}{$H+}  //  this code is shared with Delphi in tiOPF project
  TMediatorView = class(TtiObject)
  protected
    procedure CheckSetupGUIandObject;
    function GetGuiControl: TComponent; virtual; abstract;
    procedure SetGuiControl(const AValue: TComponent); virtual;
  ....
  end;
-------------[ tiMediators.pas ]------------------
  {$mode objfpc}{$H+}
  TMediatorCheckBoxView = class(TMediatorView)
  private
    FEditControl: TfpgCheckBox;
    function    GetGUIControl: TComponent; override;
    procedure   SetGUIControl(const AValue: TComponent);override;
  protected
    procedure   UpdateGuiValidStatus(pErrors: TtiObjectErrors); override;
  .....
  end;
----------------------------------------

Delphi 7 correctly reported that GetGUIControl and SetGUIControl in tiMediator has the wrong visibility level. You can't make a method less visible in a descendant class. The GetGUIControl and SetGUIControl methods it tiMediator should have been 'protected' and not 'private'.

I double checked my fpc verbosity level parameters. I have Error, Warning, Notes, Hints and General Info enabled.

The code in tiMediator.pas should have been as follows....

-------------[ tiMediators.pas ]------------------
  {$mode objfpc}{$H+}
  TMediatorCheckBoxView = class(TMediatorView)
  private
    FEditControl: TfpgCheckBox;
  protected
    function    GetGUIControl: TComponent; override;
    procedure   SetGUIControl(const AValue: TComponent);override;
    procedure   UpdateGuiValidStatus(pErrors: TtiObjectErrors); override;
  .....
  end;
----------------------------------------

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote 6 lines
Hi, Last night I ported a unit in fpGUI to VCL using Delphi 7. Delphi 7 reported a lot of warnings I never saw under FPC 2.2.3 or FPC 2.2.0 Here is one such example: Method visibility level

Here is all the hints/messages relating to the tiMediators.pas unit. As you can see, no warnings or error messages regarding the method visibility issue.

----------[ all and hidden messages copied from Lazarus Message window] -------------------
.....
Compiling ./gui/tiMediators.pas
/home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(255,44) Hint: Local variable "Ma" does not seem to be initialized /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(255,41) Hint: Local variable "Mi" does not seem to be initialized tiMediators.pas(107,35) Hint: Parameter "Sender" not used /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(107,52) Hint: Parameter "APosition" not used
/home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(388,44) Hint: Local variable "Ma" does not seem to be initialized /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(388,41) Hint: Local variable "Mi" does not seem to be initialized Compiling ./gui/tiListMediators.pas
.....
-----------------------------

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote 23 lines
Here is all the hints/messages relating to the tiMediators.pas unit. As you can see, no warnings or error messages regarding the method visibility issue. ----------[ all and hidden messages copied from Lazarus Message window] ------------------- ..... Compiling ./gui/tiMediators.pas /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(255,44) Hint: Local variable "Ma" does not seem to be initialized /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(255,41) Hint: Local variable "Mi" does not seem to be initialized tiMediators.pas(107,35) Hint: Parameter "Sender" not used /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(107,52) Hint: Parameter "APosition" not used /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(388,44) Hint: Local variable "Ma" does not seem to be initialized /home/graemeg/programming/fpgui/extras/tiopf/gui/tiMediators.pas(388,41) Hint: Local variable "Mi" does not seem to be initialized Compiling ./gui/tiListMediators.pas ..... -----------------------------

For completeness, I duplicated the issues again under Delphi 7 so I could post the exact compiler message produced by Delphi.

------------------[ Delphi 7 messages ]------------------ Build

[Hint] tiMediators.pas(53): Overriding virtual method 'TMediatorCheckBoxView.GetGUIControl' has lower visibility (private) than base class 'TMediatorView' (protected)

[Hint] tiMediators.pas(54): Overriding virtual method 'TMediatorCheckBoxView.SetGUIControl' has lower visibility (private) than base class 'TMediatorView' (protected)

------------------------------------------------

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email