I have an Interface
IMyInterface<T>
and a class
TMyClass<T>
and now I want that I can only pass classes to TMyClass as a type, that also implement IMyInterface.
First I tried
TMyClass<T:IMyInterface<T>>
but as expected, now the compiler wants me to give him a type which implements an interface with the type of class itself that implements the interface
Second try was
TMyClass<D,T:IMyInterface<D>>
where I thought, D would then be the shared DataType, both TMyInterface and TMyClass would use.
So after declaring the class implementing the interface
TMyIntegerClass = class(TInterfacedObject,IMyInterface<Integer>)
The declaration
GMyClass:TMyClass<Integer,TMyIntegerClass>
failed with compiler error:
E2514 Type parameter 'D' must support interface 'IMyInterface<System.Integer>'
Any pointers?
TMyClass<D; T: IMyInterface<D>>, analogue to parameters of a function?