Anybody here knows since when we don't have to write <T> when calling generic ProcSomething<T>(param: T)?

It was brought to my attention today that the following code compiles and works as expected and I was quite surprised.

program Project17;

{$APPTYPE CONSOLE}

{$R *.res}

uses
System.SysUtils;

type
TGeneric = class
class procedure GuessTheType<T>(const value: T);
end;

var
x: Exception;
s: TSimpleRWSync;

{ TGeneric<T> }

class procedure TGeneric.GuessTheType<T>(const value: T);
begin
end;

begin
TGeneric.GuessTheType<Exception>(x);
TGeneric.GuessTheType(x);
TGeneric.GuessTheType(s);
end.

A quick look into the generated assembler code proves that the type is indeed resolved correctly:

Project17.dpr.26: TGeneric.GuessTheType<Exception>(x);
0041C530 8B151C484200 mov edx,[$0042481c]
0041C536 A1F4974100 mov eax,[$004197f4]
0041C53B E84CD3FFFF call TGeneric.GuessTheType<System.SysUtils.Exception>
Project17.dpr.27: TGeneric.GuessTheType(x);
0041C540 8B151C484200 mov edx,[$0042481c]
0041C546 A1F4974100 mov eax,[$004197f4]
0041C54B E83CD3FFFF call TGeneric.GuessTheType<System.SysUtils.Exception>
Project17.dpr.28: TGeneric.GuessTheType(s);
0041C550 8B1520484200 mov edx,[$00424820]
0041C556 A1F4974100 mov eax,[$004197f4]
0041C55B E83CD3FFFF call TGeneric.GuessTheType<System.SysUtils.TSimpleRWSync>

Tested in Berlin and Tokyo.
Shared publiclyView activity