Skip to content

Instantly share code, notes, and snippets.

@michaliskambi
Last active February 27, 2024 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaliskambi/921b73e68285e26269fcdb610df3f310 to your computer and use it in GitHub Desktop.
Save michaliskambi/921b73e68285e26269fcdb610df3f310 to your computer and use it in GitHub Desktop.
In FPC 3.3.1, accessing private field (in generic) from the specialization is not allowed anymore
{$mode objfpc}{$H+}{$J-}
unit MyGenericClass;
interface
type
generic TMyGenericClass<T> = class
private
PrivateInClass: T;
public
PublicInClass: T;
end;
implementation
end.
{$mode objfpc}{$H+}{$J-}
uses MyGenericClass;
type
TMyClass = class(specialize TMyGenericClass<Integer>)
procedure MyMethod;
end;
procedure TMyClass.MyMethod;
begin
PrivateInClass := 123; // works in FPC 3.2.2, doesn't in FPC 3.3.1 (and FPC 3.3.1 is better IMHO!)
PublicInClass := 123;
end;
begin
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment