[fpc-devel] FPC missed method visibility issue

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Aug 27 09:19:09 CEST 2008


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/



More information about the fpc-devel mailing list