fpc/tests/test/timpfuncspez12.pp
Sven/Sarah Barth 90844c2027 * fix #35261: apply slightly adjusted changes by Ryan Joseph to implement support for implicit generic function specializations
The main adjustments were as follows:
  - fixing coding style and identation
  - fixing some typos
  - using a better name for the property in tcallcandidates which holds the symbols created for anonymous parameter values
2022-04-20 18:59:31 +02:00

27 lines
517 B
ObjectPascal

{$mode objfpc}
{$modeswitch implicitfunctionspecialization}
{
Test specialized arrays and array constructors
}
program timpfuncspez12;
uses
typinfo;
type
generic TMyArray<T> = array of T;
generic function DoThis<T>(a: specialize TMyArray<T>): TTypeKind;
begin
writeln(GetTypeKind(T), ': ', Length(a));
result := GetTypeKind(T);
end;
begin
if DoThis(['a','b','c']) <> tkChar then
Halt(-1);
if DoThis(['aaa','bbb','ccc']) <> tkString then
Halt(-1);
if DoThis([1,2,3]) <> tkInteger then
Halt(-1);
end.