mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 08:09:33 +02:00

* When building the typename for a generic use the full typename including it's surrounding object- or abstractrecorddefs. This allows that a nested non-generic type of a generic type A can be used as type arguments for more than one specialization of another generic B (there were some problems when B e.g. defined a pointer to the type argument's type) * Always CRC the constructed specialization name as otherwise it might reach the limit of 255 characters (not yet including unit name, method name or method arguments) Note: Errors like "expected XYZ, but got ABC" will need to be adjusted to use the prettyname... * increased PPU version + added test for above's point 1 git-svn-id: trunk@20149 -
46 lines
795 B
ObjectPascal
46 lines
795 B
ObjectPascal
{ %NORUN }
|
|
|
|
{ This tests that the two specializations of TUsedGeneric (once with
|
|
TGeneric<LongInt>.TSubType and once with TGeneric<Pointer>.TSubType) inside
|
|
TGeneric are unique }
|
|
|
|
program tgeneric72;
|
|
|
|
{$mode objfpc}
|
|
|
|
type
|
|
generic TUsedGeneric<T> = class
|
|
type
|
|
PT = ^T;
|
|
var
|
|
f: PT;
|
|
end;
|
|
|
|
generic TGeneric<T> = class
|
|
type
|
|
TSubType = record
|
|
Field: T;
|
|
end;
|
|
PSubType = ^TSubType;
|
|
TMyUsedGeneric = specialize TUsedGeneric<TSubType>;
|
|
private
|
|
f: PSubType;
|
|
public
|
|
function GetUsedGeneric: TMyUsedGeneric;
|
|
end;
|
|
|
|
function TGeneric.GetUsedGeneric: TMyUsedGeneric;
|
|
begin
|
|
Result := TMyUsedGeneric.Create;
|
|
Result.f := f;
|
|
end;
|
|
|
|
type
|
|
TGenericLongInt = specialize TGeneric<LongInt>;
|
|
TGenericPointer = specialize TGeneric<Pointer>;
|
|
|
|
begin
|
|
|
|
end.
|
|
|