Generics in current FPC trunk

Thomas Kurz via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <[email protected]>
Hello,

I have noticed, that this construct fails in current trunk version:

unit a;
type generic TFoo<T> = record
  privat FField: integer;
end;

unit b;
type TBar = specialize TFoo<Bar>;
type TBarHelper = type helper for TBar
  procedure DoSomething;
end;

procedure TBarHelper.DoSomething;
begin
  FField := 0;   // <-- access to `private` field forbidden due to different unit
end;

So, in the specialized record, private fields are no longer accessible. This used to work some time ago (about 1 year). I do fully understand that it is forbidden, because it's the way "private" is meant to be.

However, I'd like to ask whether this behavior change is intentional or a regression. If it's intentional, we need `protected` fields in records, too, imho. Otherwise, there'd be no way to access a private field in a specialized type if it has been defined in the generic type. And there may be good reasons not to make it public.

Kind regards,
Thomas

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.