Sign in Join

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

Mailing lists / fpc-devel / 2024-02

Exact rules for "strict protected"

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Martin Frb

https://www.freepascal.org/docs-html/ref/refse35.html

Show quoted text 7 lines
Strict Protected Is the same as Protected, except that the members of a Protected section are also accessible to other classes implemented in the same unit. Strict protected members are only visible to descendent classes, not to other classes in the same unit.

In the below

TSubFoo can see the strict proctected TTest.
So therefore TSubFoo does not count as "not to other classes in the same unit."
Well, it is another class, but it is within the class TFoo.

TSubBar is also another class, but it is within TBar. And for TBar we have "only visible to descendent classes" => TBar should see TTest. And since TSubBar is in TBar?

So the below code have that error, or is it a bug? An if it should, what is the correct exact description of "Strict protected"?

program Project1;
type
   TFoo = class
   strict protected type
     TTest = record end;
   private type
     TSubFoo = class
       a: TTest;
     end;
   end;
   TBar = class(TFoo)
   private type
     TSubBar = class
       a: TTest;  // project1.lpr(15,10) Error: Identifier not found "TTest"
     end;
   end;
begin
end.

Reply by email