Last active
February 27, 2024 11:05
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{$mode objfpc}{$H+}{$J-} | |
unit MyGenericClass; | |
interface | |
type | |
generic TMyGenericClass<T> = class | |
private | |
PrivateInClass: T; | |
public | |
PublicInClass: T; | |
end; | |
implementation | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{$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