I'm using generics a lot and one problem I am always facing is one cannot tell which specialization caused an error. I better explain it with some example code:
type
generic gTestGeneric < T > = class ( TObject )
SomeField: T;
procedure CreateField;
end;
TTestObj1 = class( TObject )
constructor Create( abc: String );
end;
TTestObj2 = class( TObject )
constructor Craete( abc: String ); // Some typo
end;
TTestGeneric1 = specialize gTestGeneric <TTestObj1>;
TTestGeneric2 = specialize gTestGeneric <TTestObj2>;
implementation
procedure gTestGeneric.CreateField;
begin
SomeField:= T.Create( 'abc' ); // Error here without telling which specialization caused the problem (In this case TTestObj2)
end;
...
This is only an example to show that sometimes errors are only caused for some specialization and there is no way to tell from the error message which specialization is causing it. Would it be very complicated to implement in the compiler? What do you think?