8238213: Method resolution should stop on static error

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2021-06-09 15:56:55 +00:00
parent 81fdeb579a
commit bb3d226a4e
3 changed files with 23 additions and 1 deletions

View File

@ -3417,7 +3417,7 @@ public class Resolve {
*/
final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) {
return phase.ordinal() > maxPhase.ordinal() ||
!sym.kind.isResolutionError() || sym.kind == AMBIGUOUS;
!sym.kind.isResolutionError() || sym.kind == AMBIGUOUS || sym.kind == STATICERR;
}
/**

View File

@ -0,0 +1,19 @@
/**
* @test /nodynamiccopyright/
* @bug 8238213
* @summary Method resolution should stop on static error
* @compile/fail/ref=ShouldStopOnStaticError.out -XDrawDiagnostics ShouldStopOnStaticError.java
*/
public class ShouldStopOnStaticError {
static void foo() {
test1(5.0);
test2((Double)5.0);
}
void test1(double d) {}
void test1(Double d) {}
void test2(Number n) {}
static void test2(Double... d) {}
}

View File

@ -0,0 +1,3 @@
ShouldStopOnStaticError.java:10:9: compiler.err.non-static.cant.be.ref: kindname.method, test1(double)
ShouldStopOnStaticError.java:11:9: compiler.err.non-static.cant.be.ref: kindname.method, test2(java.lang.Number)
2 errors