提交 1939638f 编写于 作者: M mcimadamore

7151070: NullPointerException in Resolve.isAccessible

Summary: Spurious accessibility check in TransTypes
Reviewed-by: jjg
上级 535a7b99
......@@ -2097,9 +2097,10 @@ public class Resolve {
* ResolveError classes, indicating error situations when accessing symbols
****************************************************************************/
public void logAccessError(Env<AttrContext> env, JCTree tree, Type type) {
AccessError error = new AccessError(env, type.getEnclosingType(), type.tsym);
logResolveError(error, tree.pos(), type.getEnclosingType().tsym, type.getEnclosingType(), null, null, null);
//used by TransTypes when checking target type of synthetic cast
public void logAccessErrorInternal(Env<AttrContext> env, JCTree tree, Type type) {
AccessError error = new AccessError(env, env.enclClass.type, type.tsym);
logResolveError(error, tree.pos(), env.enclClass.sym, env.enclClass.type, null, null, null);
}
//where
private void logResolveError(ResolveError error,
......
......@@ -107,7 +107,7 @@ public class TransTypes extends TreeTranslator {
make.at(tree.pos);
if (!types.isSameType(tree.type, target)) {
if (!resolve.isAccessible(env, target.tsym))
resolve.logAccessError(env, tree, target);
resolve.logAccessErrorInternal(env, tree, target);
tree = make.TypeCast(make.Type(target), tree).setType(target);
}
make.pos = oldpos;
......
/*
* @test /nodynamiccopyright/
* @bug 7151070
* @summary NullPointerException in Resolve.isAccessible
* @compile/fail/ref=T7151070.out -XDrawDiagnostics T7151070.java
*/
class T7151070a {
private static class PrivateCls { }
public static class PublicCls extends PrivateCls { }
public void m(PrivateCls p) { }
}
class T7151070b {
public void test(Test<T7151070a.PublicCls> obj, T7151070a outer) {
outer.m(obj.get());
}
public static class Test<T> {
public T get() {
return null;
}
}
}
T7151070.java:17:24: compiler.err.report.access: T7151070a.PrivateCls, private, T7151070a
1 error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册