Let's say I have a class with two generic methods:
TMyClass = class
procedure DoWith<T: class> (obj: T);
procedure DoFor<T: class> ( proc: TProc<T> );
end;
Now, when I want to call either of these two methods with a specific type parameter, Delphi can infer the type for the DoWith method, so I can call it with either
MyClass.DoWith <TButton> ( MyButton )
or
MyClass.DoWith ( MyButton )
The Delphi Compiler will happily compile both.
But if I omit the type parameter in the DoFor method, the Delphi compiler complains about the missing type parameter:
MyClass.DoFor<TButton>(procedure (Button: TButton) begin .... end); // compiles
MyClass.DoFor(procedure (Button: TButton) begin .... end); // doesn't compile
Now my question is: Is this just a shortcoming of the compiler, or is there any logical reason (that I haven't figured out yet) that prohibits the compiler from correctly inferring the type for the DoFor method?