This is a follow-up question to: How to hide a protected procedure of an object?
(I'm a bit fuzzy on the whole class helper concept)
Suppose I have an class like:
type
TShy = class(TObject)
strict private
procedure TopSecret;
private
procedure DirtyLaundry;
protected
procedure ResistantToChange;
end;
I know I can access the private method if I have the source code by adding a descendent class in the same unit.
I have 2 questions:
- How do I employ a class helper to access the strict private
member?
- Can I use a class helper in a separate unit to access (strict) private members?
Up to, and including Delphi 10.0 Seattle, you can use a class helper to access
strict protected
andstrict private
members, like this:However, starting with Delphi 10.1 Berlin, this no longer works! Class helpers can no longer access
strict protected
,strict private
orprivate
members. This "feature" was actually a compiler bug that Embarcadero has now fixed in Berlin. You are out of luck.Access to
private
andstrict private
members of a class withclass helpers
was removed in Delphi 10.1 Berlin. See Closing the Class Helpers Private Access Loophole.But there is still an open loophole: