-
Bug
-
Resolution: Not an Issue
-
P2
-
7
-
generic
-
generic
The fix to 7042566(?) results in two methods such as
void foo(int... ia) {}
void foo(Object... oa {}
as now seen as both matching when foo is given two ints.
Test code:
public class test4 {
public int foo(int ... vai) { return 1; }
public int foo(Object ... vaO) { return 2; }
//TEST: choose best of overloaded methods
public int test() {
int i1 = 1;
int i2 = 2;
int ret = foo(i1,i2); //should choose method 1
return ret;
}
public static void main(String[] args) {
test4 tv = new test4();
System.out.println( tv.test()==1?"PASS":"FAIL" );
}
}
Error message:
h:\ws\7_int\tools\src\javac\varargs\test4]javac test4.java
test4.java:18: error: reference to foo is ambiguous, both method foo(int...) in test4 and method foo(Object...) in test4 match
int ret = foo(i1,i2); //should choose method 1
^
1 error
void foo(int... ia) {}
void foo(Object... oa {}
as now seen as both matching when foo is given two ints.
Test code:
public class test4 {
public int foo(int ... vai) { return 1; }
public int foo(Object ... vaO) { return 2; }
//TEST: choose best of overloaded methods
public int test() {
int i1 = 1;
int i2 = 2;
int ret = foo(i1,i2); //should choose method 1
return ret;
}
public static void main(String[] args) {
test4 tv = new test4();
System.out.println( tv.test()==1?"PASS":"FAIL" );
}
}
Error message:
h:\ws\7_int\tools\src\javac\varargs\test4]javac test4.java
test4.java:18: error: reference to foo is ambiguous, both method foo(int...) in test4 and method foo(Object...) in test4 match
int ret = foo(i1,i2); //should choose method 1
^
1 error
- relates to
-
JDK-7042566 Regression: new ambiguity between varargs method
- Closed