Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-05

Sven, please look into "cannot return generic derived class" issue

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anthony Walter

Sven,

When you have the time could you look at issue #22019 titled "Cannot return generic derived class"? I think it's kind of a big issue because it prevents anyone from returning a subclass of a generic type. I just want to know that's you've read the bug report and see/understand the issue.

In a nutshell you currently cannot write something like:

function TList<T>.GetEnumerator: TEnumerator<T>;
begin
  // TListEnumerator<T> inherits from TEnumerator<T>
  return TListEnumerator<T>.Create(Self);
end;

There are other examples, but I think the above and the details provided in the bug report should be enough to convey the problem.

Thanks Sven! We all very much appreciate your work!

Reply by email

Sven Barth
to Anthony Walter
Anthony Walter wrote 6 lines
Sven, When you have the time could you look at issue #22019 titled "Cannot return generic derived class"? I think it's kind of a big issue because it prevents anyone from returning a subclass of a generic type. I just want to know that's you've read the bug report and see/understand the issue.

Yes, I've seen this report (as well as all other generic reports - at least if they have the tag "generics"). :)

Show quoted text 10 lines
In a nutshell you currently cannot write something like: function TList<T>.GetEnumerator: TEnumerator<T>; begin // TListEnumerator<T> inherits from TEnumerator<T> return TListEnumerator<T>.Create(Self); end; There are other examples, but I think the above and the details provided in the bug report should be enough to convey the problem.

*looks at the bug report*

Ah, that was that one. Potentially I have it on my ToDo list already. It will depend on how much work it needs whether I'll solve it "now" or when I start working on generic methods/functions where I plan to do some "cleaning up" of the code related to generics as well.

Thanks Sven! We all very much appreciate your work!

I try to do as good as my free time allows :)

Regards,
Sven

Reply by email