The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,762 other followers

Delphi generic nested classes

Posted by jpluimers on 2019/08/21

Reminder to Self: do not nest T generic types as you’re in for a surprise.

Source: [WayBackDelphi generic nested classes

Via: [WayBack] An interesting question over on SO relating to nested generic classes… – David Heffernan – Google+

The surprise:

what type would you expect obj.x to be? Integer or string?

The compiler hint:

[dcc32 Hint]: H2509 Identifier 'T' conflicts with type parameters of container type

–jeroen

2 Responses to “Delphi generic nested classes”

  1. Sebastian Jänicke said

    I did not try it yet, but I would expect it to be of type Integer. This would be the only logical way as T is already defined when you get to the inner class. So there should be no way to redeclare this type. I would be very surprised, if this would be different.

    • Sebastian Jänicke said

      I would have expected a compiler error to be honest (redeclared type or something like this).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: