posted 16 years ago
Hi guys. I have two questions about generic method overloading.
With regard to this code:
(a) When methods 1 and 3 are commented in, compiler complains about 'call 2', presumably because Number implements Comparable. If I comment out 'method 1', the compiler chooses the method with the narrower upper bound. Is there a rule about overloading generic methods to be deduced from that? Does this have something to do with 'covariance'?
(b) When methods 3 and 4 are commented out the autoboxing of calls 2 and 3 works fine, however when 3 and 4 are in (and method 1 out per a), call 2 fails with:
and call 3 with:
If I explicitly box them myself it works as expected. That seems strange to me.
Thanks.
[ June 21, 2008: Message edited by: Mike Mitchell ]