EVALUATION
Change in file Check.java. Putting one condition to check for method signature.
void duplicateErasureError(int pos, Symbol sym1, Symbol sym2)
{
if (!sym1.type.isErroneous() && !sym2.type.isErroneous())
{
log.error(pos, "name.clash.same.erasure", sym1, sym2);
}
}
-----------------------------------
Comment by Maurizio
I approve this fix, as I think that it's good to move error checking earlier in the compiler pipeline. But I must warn you that the fix, as it is now is incomplete, in the sense that there is a very similar test case that, if I'm right, is not covered by your fix; here's the code:
import java.util.List;
class JavaDocGenerics {
public void a(String[] s){}
public void a(String... s){}
}
If you run javadoc on this source, again javadoc fails to detect this error (you cannot have two methods one accepting a varargs and the other one accepting an array - it's a duplicate error, more or less for the same reason for which it's an error to accept two methods with the same erasure in the same class).
I know that this testcase is not directly related to CR 6709709 and, perhaps, it is outside the scope of this escalation. It's up to you whether to keep the fix as it is now, or to go for a different one that tackles also the varargs issue. Should you go for the latter option, I'd be happy to help, as we already have that fixed in JDK 7.
Maurizio
----------
Some more cases suspected by Maurizio:
E.g. another example of thing that might fail with javadoc:
class A<X extends Number> {
void m(X o) {}
}
class B extends A<Integer> {
void m(Integer o) {} //ok overrides m(X), where X is Integer
void m(Number o) {} //error, m(Number) does not override m(X) in A, but have the same erasure
}
|