@TRonOk, in that case please show me that you can call the method named Foo of my class (without specialization to my class TFoo) :-\
And yet any method can be called - why can't we do the same with types?
Besides, you can do it like this:Yes, because T2 get its actual type during specialization :)
Generics run basically in two passes, first the parsing of the generic structure, where some basic error checking is performed. The main point here is that any accesses onto the generic parameters are (or should not) be checked.Thank you for the explanation and yes it should not be checked because it would be impossible to check at that time (e.g. compiler does not know at that time what the user has in mind). In that regards I might be wrong with my remark that it should be flagged an error when not being specialized. I would at least expect some warning (but might be wrong about that as well).
The second pass then is the specialization pass. Here the placeholder generic parameters are replaced with the actual values. Basically the parser acts here exactly as in non generic code, meaning here all errors will be thrown.Ok. Bringing ALLIGATOR's latest example into that equation (thank you ALLIGATOR) the example will show its colours when specializing.
Here's a fully working versionThank you very much for the example ALLIGATOR. Seems that initially I misinterpreted your example.
I was looking for a possible modeswitch that would allow duplicate identifiers in ObjFPC mode, but there doesn't seem to be such a switch (although such a switch would be useful in some situations).
I also found a discussion from way back in 2013 where Sven seemed to be talking about possibly adding a similar modeswitch in the future that would work for ObjFPC mode in this situation as well
I wonder if there is any progress in this direction since then? )
{$Modeswitch DuplicateLocals}
Quote{$Modeswitch DuplicateLocals}
Yes, I've seen this switch and even tried it, but it doesn't work in this case (like in my last example - it still swears at duplicate identifiers, then maybe it's a bug??).