fpc/tests/webtbs/tw10247.pp
svenbarth 0d1d3d8e72 Fix for Mantis #25917. With this change the visibility of type parameters is changed from public to strict private as otherwise unexpected (and "unworkaroundable") errors might occur (like the one in the mentioned bug report).
pgenutil.pas:
  * parse_generic_parameters & insert_generic_parameter_types: create the type parameter symbols as strict private instead of public (which is the default visiblity)

* adjusted two tests which relied on this behavior (that's why I fixed the type aliases previously)
+ added test

git-svn-id: trunk@29486 -
2015-01-16 17:02:02 +00:00

72 lines
1.1 KiB
ObjectPascal

{$mode objfpc}{$h+}
uses classes, sysutils;
type
generic TNode<T> = class
public
type
TAlias = T;
PT = ^T;
private
var
Data: T;
public
constructor Create;
destructor Destroy; override;
end;
generic TContainer<T> = class
public
type
TTNode = specialize TNode<T>;
private
var
Data: TTNode;
public
constructor Create;
destructor Destroy; override;
function GetAddr: TTNode.PT;
procedure SetV(v: TTNode.TAlias);
end;
constructor TNode.Create;
begin
end;
destructor TNode.Destroy;
begin
inherited Destroy;
end;
constructor TContainer.Create;
begin
Data:=TTNode.Create;
end;
destructor TContainer.Destroy;
begin
Data.Free;
inherited Destroy;
end;
function TContainer.GetAddr: TTNode.PT;
begin
result := @Data.Data;
end;
procedure TContainer.SetV(v: TTNode.TAlias);
begin
Data.Data:=v;
end;
type
TStringContainer=specialize TContainer<String>;
var
c : TStringContainer;
begin
c:=TStringContainer.Create;
c.SetV('abc');
Writeln(HexStr(c.GetAddr));
end.