If I derive a specialized class from a generic class (which is defined in a separate unit), then in that class (and instances of that class) I have access to private fields of that class.
Regarding terminology: you do
not “derive” a specialized class from a generic one, you “specialize” a generic class. And your
TBarChar and
TBarFoo “derive” from a specialized class (which for all intents and purposes is just a normal class now).
Never mind that the code is bogus and would crash instantly
It
should not work. It currently works, because the compiler is essentially recreating the class inside your main program file thus it's essentially an access from the same unit. As the compiler could in theory however reuse the specialization from another unit the code would then fail. Delphi behaves correctly here. Please report as a bug.