I guess its the wrong error message...
Starting at
TFoo = class
generic procedure Bar<T>; virtual;
end;
gives: project1.lpr(8,38) Error: Generic methods can not be virtual
And it makes sense.
1) Virtual methods must be in the VMT.
2) The size and order of the VMT must be known (per class) and not change.
The 2nd means, imagine
- The VMT has size=10 in the unit that defines that class
- another unit_X adds a specialization at position 11
- another unit_Y also adds a specialization, it does not know about unit_X, so also at position 11.
- Or an inherited class already has put its virtual method at position 11
...
Then if code tries to use this method, only one can be at pos 11.
Methods of interfaces are handled like virtual methods. they are listed in a table and accessed by position.
So if my understanding is right, they can not (as in: are technically not possible to) be generic.
Just the error message seems an odd choice....