Simplifying reified generics with partial specialization

Simon Ochsenreither simon at ochsenreither.de
Mon Jan 5 15:07:07 UTC 2015


> This would mean that ArrayList<int> will implement List<Integer> (and will
> therefore extend List and List<?>) and Object will essentially be the Any
> type (and List<int>, if allowed, would just be an alias for List<Integer>).
The issue is that you can do things with ArrayList<Integer> that you 
can't do with ArrayList<int>.
What will happen when you do call "list.add(null)"? Will it take the 
array of ints, allocate a new array of Integers, box all ints to 
Integers and copy them over to the new reference array, then add null as 
the last element?

(I think I already mentioned an example where such issues get even more 
pronounced in one of my earlier emails. E. g. what's supposed to happen 
if you add a String to your specialized covariant immutable 
data-structure of ints? If you suggest that if a generic parameter is 
instantiated with a value type the generic bounds are collapsed, then 
that's what Brian was saying in the beginning.)



More information about the valhalla-dev mailing list