fpc/tests/webtbs/tw21350b.pp
svenbarth d2fabd2a22 Fix for Mantis #21350
+ pgenutil.pas: 
    add a procedure which adds a type symbol to a non-Delphi-mode generic class or record which has the same name as the unit global dummy symbol for that generic. I don't know why I had that idea earlier as this will simplify some of the conditions in the parser again (I haven't changed these yet, but I hope to do that at least when I start working on generic functions).
* pgenutil.pas, generate_specialization:
    correctly handle "specialize TSomeGeneric<T>" as method parameter in a generic with the newly added rename symbol
* pdecobj.pas, object_dec & ptype.pas, record_dec: 
    call the procedure to add the rename symbol (the procedure checks whether the mode is correct)
* ppu.pas: 
    increase PPU version so that we don't use non-Delphi mode units with generics, but without the rename symbol
+ added tests:
    the one in webtbs are for classes/objects and those in test are for records

git-svn-id: trunk@21603 -
2012-06-14 07:07:28 +00:00

48 lines
725 B
ObjectPascal

{$mode objfpc}{$h+}
unit tw21350b;
interface
type
{ TPointEx }
generic TPointEx<T> = object
X, Y: T;
function Create(const AX, AY: T): TPointEx;
class procedure Swap(var A, B: TPointEx); static;
class procedure OrderByY(var A, B: TPointEx); static;
end;
//TPoint = specialize TPointEx<integer>;
TPointF = specialize TPointEx<single>;
implementation
{ TPoint<T> }
function TPointEx.Create(const AX, AY: T): TPointEx;
begin
result.X:=AX;
result.Y:=AY;
end;
class procedure TPointEx.Swap(var A, B: TPointEx);
var
tmp: TPointEx;
begin
tmp:=A;
A:=B;
B:=tmp;
end;
class procedure TPointEx.OrderByY(var A, B: TPointEx);
begin
if A.Y > B.Y then
TPointEx.Swap(A,B);
end;
end.