KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have started using of generics in Delphi 2010 but I have a problem when compiling this piece of code: TThreadBase = class( TThread ) ... end; TThreadBaseList<T: TThreadBase> = class( TObjectList<T> ) ... end; TDataProviderThread = class( TThreadBase ) ... end; TDataCore = class( TInterfacedObject, IDataCore ) private FProviders: TThreadBaseList<TDataProviderThread>; ... end; Then I have some nested procedure: procedure MakeAllThreadsActive(aThreads: TThreadBaseList<TThreadBase>); begin ... end; And finally I want to call this nested procedure in the code of TDataCore class: MakeAllThreadsActive(FProviders); But compiler does not want to compile it and it says ('<>' brackets are replaced by '()'): [DCC Error] LSCore.pas(494): E2010 Incompatible types: 'TThreadBaseList(TThreadBase)' and 'TThreadBaseList(TDataProviderThread)' I do not understand it although TDataProviderThread is descendant of TThreadBase. I had to fix it by hard typecasting: MakeAllThreadsActive(TThreadBaseList<TThreadBase>(FProviders)); Does anybody know why the compiler says this error?
Tags (comma-separated)
Save Edits
Cancel