RE: [Java Spec Report] overloading of varargs
"Tim Hanson" <[email protected]> Thu, 29 Jul 2004 10:24:55 -0700
| Newsgroups | gmane.comp.java.spec-report |
|---|---|
| Message-ID | <[email protected]> |
Section 15.12.2.5 has explicit rules for dealing with variable arity method= s. It seems to describe exactly the behaviour you expect.=20 It refers to the types of the parameters as T1, ..., Tn-1, Tn[] && U1, ...,= Uk-1, Uk[] This implies that for the last parameter for both methods the comparisons a= re done against the element type of the array, not the array type. It looks like an implementation bug to me. Tim > -----Original Message----- > From: Remi Forax [mailto:[email protected]] > Sent: Thursday, July 29, 2004 2:29 AM > To: [email protected] > Subject: [Java Spec Report] overloading of varargs >=20 >=20 > I prepare a course on java, so i made some tests and, > i have a case a little bit strange : >=20 > class A { > void m(int... a) {} > void m(double... b) {} >=20 > void g(Object... o) {} > void g(String... s) {} > } >=20 > new A().m(3) raise an ambiguity and > new A().g(new Object()) don't. >=20 > Using the JLS 3, section 15.12.2.4 says the two m are applicables > and section 15.12.2.5 describe th most specific method > using subtyping relationship. > So because int[] and double[] have no subtyping > relationship, a call to m with an int is ambiguous. >=20 > I thing in case of varargs, it seems to me more logic if methods > are compared using the component type of the array and not > the array itself (here double vs int and not double[] vs int[]) >=20 > R=E9mi Forax >=20 >=20 >=20 >=20 > ------------------------ Yahoo! Groups Sponsor=20 > --------------------~-->=20 > Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. > Now with Pop-Up Blocker. Get it for free! > http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM > -------------------------------------------------------------- > ------~->=20 >=20 > To unsubscribe from this mailing list, send an email to: > [email protected] >=20=20 > Yahoo! Groups Links >=20 >=20 >=20 >=20=20 >=20 >=20 ------------------------ Yahoo! Groups Sponsor --------------------~-->=20 Yahoo! Domains - Claim yours for only $14.70 http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/5cFolB/TM --------------------------------------------------------------------~->=20 To unsubscribe from this mailing list, send an email to: [email protected] =20 Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/java-spec-report/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ =20