8249829: javac is issuing an incorrect static access error
Reviewed-by: jlahoda
This commit is contained in:
parent
af8c3b4a7e
commit
6c2ff1781b
@ -2289,13 +2289,11 @@ public class Resolve {
|
||||
}
|
||||
|
||||
boolean isInnerClassOfMethod(Symbol msym, Symbol csym) {
|
||||
if (csym.owner == msym && !csym.isStatic()) {
|
||||
return true;
|
||||
} else if (csym.owner.kind == TYP) {
|
||||
return isInnerClassOfMethod(msym, csym.owner);
|
||||
} else {
|
||||
return false;
|
||||
while (csym.owner != msym) {
|
||||
if (csym.isStatic()) return false;
|
||||
csym = csym.owner.enclClass();
|
||||
}
|
||||
return (csym.owner == msym && !csym.isStatic());
|
||||
}
|
||||
|
||||
/** Find an unqualified type symbol.
|
||||
|
@ -800,6 +800,48 @@ public class RecordCompilationTests extends CompilationTestCase {
|
||||
}
|
||||
"""
|
||||
);
|
||||
|
||||
// positive cases
|
||||
assertOK(
|
||||
"""
|
||||
import java.security.*;
|
||||
class Test {
|
||||
static Test newInstance(Object provider) {
|
||||
return new Test() {
|
||||
private final PrivilegedExceptionAction<KeyStore> action = new PrivilegedExceptionAction<KeyStore>() {
|
||||
public KeyStore run() throws Exception {
|
||||
if (provider == null) {}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
"""
|
||||
);
|
||||
|
||||
assertOK(
|
||||
"""
|
||||
import java.security.*;
|
||||
class Test {
|
||||
static Test newInstance(Object provider) {
|
||||
return new Test() {
|
||||
int m(PrivilegedExceptionAction<KeyStore> a) { return 0; }
|
||||
{
|
||||
m(
|
||||
new PrivilegedExceptionAction<KeyStore>() {
|
||||
public KeyStore run() throws Exception {
|
||||
if (provider == null) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
public void testReturnInCanonical_Compact() {
|
||||
|
Loading…
Reference in New Issue
Block a user