fpc/tests/webtbs/tw21051.pp
svenbarth 68a3827539 Fix for Mantis #21051. Correctly handle specializations that occur during the specialization of methods.
cclasses.pas:
  + TFPHashList & TFPHashObjectList: add WhileEachCall methods that walk the list like ForEachCall does, but uses a while-loop instead of a for-loop
psub.pas, generate_specialization_procs:
  * use WhileEachCall instead of ForEachCall as new defs can be added during the specialization that need to be specialized as well

+ added test

git-svn-id: trunk@25577 -
2013-09-26 08:15:58 +00:00

55 lines
820 B
ObjectPascal

{ %NORUN }
program tw21051;
{$mode Delphi}{$H+}
type
TCustomInner<T> = class abstract
protected
function SomeMethod: T; virtual; abstract;
end;
TContainer<T> = class
public
function GetInner: TCustomInner<T>;
end;
TInner<T> = class(TCustomInner<T>)
private
FContainer: TContainer<T>;
protected
function SomeMethod: T; override;
public
constructor Create(AContainer: TContainer<T>);
end;
function TContainer<T>.GetInner: TCustomInner<T>;
type
InnerClass = TInner<T>;
begin
Result := InnerClass.Create(Self);
end;
function TInner<T>.SomeMethod: T;
begin
end;
constructor TInner<T>.Create(AContainer: TContainer<T>);
begin
FContainer := AContainer;
end;
procedure Test;
var
C: TContainer<string>;
begin
C := TContainer<string>.Create;
end;
begin
Test;
end.