8185451: Misleading 'cannot be accessed from outside package' diagnostic for inconsistent varargs override

Reviewed-by: mcimadamore
This commit is contained in:
Vicente Romero 2017-11-27 13:26:31 -05:00
parent 966746dba3
commit 030e675ed3
3 changed files with 25 additions and 1 deletions

View File

@ -1548,7 +1548,8 @@ public class Resolve {
boolean allowBoxing,
boolean useVarargs) {
if (sym.kind == ERR ||
!sym.isInheritedIn(site.tsym, types)) {
(site.tsym != sym.owner && !sym.isInheritedIn(site.tsym, types)) ||
!notOverriddenIn(site, sym)) {
return bestSoFar;
} else if (useVarargs && (sym.flags() & VARARGS) == 0) {
return bestSoFar.kind.isResolutionError() ?

View File

@ -0,0 +1,21 @@
/*
* @test /nodynamiccopyright/
* @bug 8185451
* @summary Misleading 'cannot be accessed from outside package' diagnostic for inconsistent varargs override
* @compile/fail/ref=MisleadingVarArgsErrorMsgTest.out -XDrawDiagnostics MisleadingVarArgsErrorMsgTest.java
*/
class MisleadingVarArgsErrorMsgTest {
class A {
void f(int... x) {}
}
class B extends A {
@Override
void f(int[] x) {}
}
{
new B().f(1);
}
}

View File

@ -0,0 +1,2 @@
MisleadingVarArgsErrorMsgTest.java:19:16: compiler.err.cant.apply.symbol: kindname.method, f, int[], int, kindname.class, MisleadingVarArgsErrorMsgTest.B, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[]))
1 error