Einzelnen Beitrag anzeigen

Der schöne Günther

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#1

Helfer funktioniert nicht bei statischen Record-Methoden

  Alt 17. Jul 2015, 17:51
Delphi-Version: XE7
Wie komme ich mit einem Record-Helfer an private statische Methoden des Records?

Delphi-Quellcode:
type
   TSomeRecord = record
      strict private procedure instanceMethod();
      strict private class procedure StaticMethod(); static;
   end;

   TSomeRecordHelper = record helper for TSomeRecord
      public procedure _instanceMethod();
      public class procedure _StaticMethod(); static;
   end;

   TMyObject = class(TObject)
      strict private class procedure StaticMethod(); virtual; abstract;
   end;

{ TSomeRecord }

procedure TSomeRecord.instanceMethod();
begin
   //
end;

class procedure TSomeRecord.StaticMethod();
begin
   //
end;

{ TSomeRecordHelper }

procedure TSomeRecordHelper._instanceMethod();
begin
   self.instanceMethod(); // Das klappt schonmal...
end;

class procedure TSomeRecordHelper._StaticMethod();
begin
   //self.StaticMethod(); // E2003: Undeklarierter Bezeichner "self"
   //StaticMethod(); // E2003: Undeklarierter Bezeichner "StaticMethod"
   //TSomeRecord.StaticMethod(); // E2361 Auf private-Symbol TSomeRecord.StaticMethod kann nicht zugegriffen werden
   //inherited StaticMethod(); // E2075 Diese Form des Methodenaufrufs ist nur in Methoden von abgeleiteten Typen erlaubt
   raise EProgrammerNotFound.Create('Delphi-Praxis, zu Hilfe!');
end;
  Mit Zitat antworten Zitat