[fpc-pascal] Is this a bug?

Anthony Walter sysrpl at gmail.com
Tue Apr 16 09:57:57 CEST 2013


I just wanted to get some opinions on this as to whether this is a bug.
Generics in 2.7.x trunk allows units which use a generic class defined in
another unit can access protected members.

Example:

unit A;

type
  TFoo<T> = class
  protected
    Bar: T;
  end;

<-- snip to next unit -->

unit B;

uses A;

Foo: TFoo<Integer>;
...
Foo.Bar := 42; // Code in unit B can access protected members of TFoo.

Should the above line generate a compiler error instead? That is ...
TFoo.Bar shouldn't visible unless your code is in Unit A or in a method of
a class which inherits TFoo<T>?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130416/124d5c50/attachment.html>


More information about the fpc-pascal mailing list