If you have to determine <T> type at runtime, than generics isn't right way to do your job, cuz they're intended to be universal. Use standard OOP features instead.
Not sure, if Lazarus supports this operation. Latest Lazarus versions should allow it. But you can just specialize your generic for certain type.
For example (Delphi syntax, as I'm not familiar to Lazarus one):
type
TBaseClass<T> = class
function DoSomething(const A, B:T):T;virtual;abstract;
end;
TIntegerClass = class(TBaseClass<Integer>)
function DoSomething(const A, B:Integer):Integer;override;
end;