View Issue Details

IDProjectCategoryView StatusLast Update
0038139FPCCompilerpublic2020-11-27 13:15
ReporterOndrej Pokorny Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.3.1 
Summary0038139: class helper: inherited property call resolves to self and not inherited
DescriptionIf a class helper redeclares a property, the inherited property cannot be accessed with the inherited keyword. The methods can.
Steps To Reproduceprogram InheritedPropertyHelper

{$ifdef fpc}
{$mode delphi}
{$else}
{$apptype console}
{$endif}

type
  TTest = class(TObject)
  private
    fPort: Integer;
    function GetPort: Integer;
    procedure SetPort(const aPort: Integer);
  public
    property Port: Integer read GetPort write SetPort;
    procedure Test;
  end;

  TTestHelper = class helper for TTest
  private
    function GetPort: Integer;
    procedure SetPort(const aPort: Integer);
  public
    property Port: Integer read GetPort write SetPort; // redeclare
    procedure Test; // redeclare
  end;

{ TTest }

function TTest.GetPort: Integer;
begin
  Result := fPort;
end;

procedure TTest.SetPort(const aPort: Integer);
begin
  fPort := aPort;
end;

procedure TTest.Test;
begin
  Writeln('TTest');
end;

{ TTestHelper }

function TTestHelper.GetPort: Integer;
begin
  Result := inherited Port;
end;

procedure TTestHelper.SetPort(const aPort: Integer);
begin
  inherited Port := aPort; // endless loop
end;

procedure TTestHelper.Test;
begin
  inherited Test; // OK
end;

var
  T: TTest;
begin
  T := TTest.Create;
  T.Test; // OK
  T.Port := 2; // endless loop
  Writeln(T.Port); // endless loop
end.
Additional InformationDelphi works OK.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-11-27 13:15 Ondrej Pokorny New Issue