tw36496b.pp 871 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. { %NORUN }
  2. (*
  3. testing application for
  4. https://forum.lazarus.freepascal.org/index.php/topic,47936.0.html
  5. *)
  6. program tw36496b;
  7. {$Mode objfpc}{$H+}
  8. generic function TestGenRecurse<T>(const AInput : T) : Boolean;
  9. begin
  10. //Result := False;
  11. (*
  12. below, if uncommented will fail to compile
  13. tester.lpr(12,19) Error: Identifier not found "TestGenRecurse$1"
  14. *)
  15. specialize TestGenRecurse<T>(AInput);
  16. specialize TestGenRecurse<String>('test');
  17. specialize TestGenRecurse<LongInt>(42);
  18. end;
  19. generic procedure TestGenRecurseProc<T>(const AInput : T);
  20. begin
  21. (*
  22. below method calls compile fine
  23. *)
  24. specialize TestGenRecurseProc<T>(AInput);
  25. specialize TestGenRecurseProc<String>('test');
  26. specialize TestGenRecurseProc<LongInt>(42);
  27. end;
  28. begin
  29. specialize TestGenRecurse<String>('testing');
  30. specialize TestGenRecurseProc<String>('testing');
  31. end.