[ nice-Feature Requests-986587 ] Restrictions on type parameter names

"SourceForge.net" <[email protected]> Sun, 06 Mar 2005 06:07:48 -0800
Newsgroups gmane.comp.lang.nice.devel
Message-ID <[email protected]>
Feature Requests item #986587, was opened at 2004-07-07 15:30
Message generated for change (Comment added) made by bonniot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=362788&aid=986587&group_id=12788

Category: None
Group: None
Status: Open
Priority: 5
Submitted By: Bryn Keller (xoltar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Restrictions on type parameter names

Initial Comment:
Part 1:

I think it would be good to report an error (or at
least a warning) when a type name is used where a type
parameter name is expected. For instance,

//Read lines from a file
class LineIterator<String> implements Iterator<String>
{
//...
}

What was intended here was

class LineIterator<String T> implements Iterator<T>
{
//...
}

but the compiler happily uses "String" as a type
parameter name, leading to much confusion when you find
out that your new LineIterator works with t243's or
something instead of Strings.


Part 2:

Perhaps even better would be to simply accept the first
syntax with the same meaning as the second example.
That is, when we see

class A<X> implements B<X>

and X is the name of a class, treat it as 

class A<X T> implements B<T>

this would certainly help convert a certain class of
errors into usable code. Whether we should complicate
the notation with this special case I'm not sure, we
should have some discussion on the subject. 

We should definitely implement the error/warning in
Part 1 in the meantime.

----------------------------------------------------------------------

>Comment By: Daniel Bonniot (bonniot)
Date: 2005-03-06 15:07

Message:
Logged In: YES 
user_id=88952

It's now possible to do
  class LineIterator implements Iterator<String>

Still, I agree that trying to shadow a toplevel type by a
type variable should not be allowed. It can be the occasion
to do so while updating the generics syntax.

----------------------------------------------------------------------

Comment By: Daniel Bonniot (bonniot)
Date: 2004-08-12 16:05

Message:
Logged In: YES 
user_id=88952

I agree the motivating case is confusing, so we should at least issue a warning.

For a good support for this case, I think the solution is as in RFE #994780: allow 
  class LineIterator implements Iterator<String>


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=362788&aid=986587&group_id=12788


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click