With b49, the following example:
public class Foo {
Class<?>[] get() { return null; }
void set(Class... c) { }
void test() {
set(get());
}
}
results in
Foo.java:7: warning: fixed-arity call of variable-arity method with inexact match for last parameter;
cast to java.lang.Class for a variable-arity call
cast to java.lang.Class[] for a fixed-arity call
set(get());
^
1 warning
Suggesting a cast from Class<?>[] to Class makes no sense. The ambiguity in this call is not obvious to me.
public class Foo {
Class<?>[] get() { return null; }
void set(Class... c) { }
void test() {
set(get());
}
}
results in
Foo.java:7: warning: fixed-arity call of variable-arity method with inexact match for last parameter;
cast to java.lang.Class for a variable-arity call
cast to java.lang.Class[] for a fixed-arity call
set(get());
^
1 warning
Suggesting a cast from Class<?>[] to Class makes no sense. The ambiguity in this call is not obvious to me.
- duplicates
-
JDK-5035307 fixed-arity warning given too often
-
- Resolved
-