提交 90149e48 编写于 作者: J jjg

6930032: fix findbugs errors in com.sun.tools.javac.comp

Reviewed-by: darcy
上级 4bd5c83b
......@@ -270,6 +270,7 @@ public class Enter extends JCTree.Visitor {
return ts.toList();
}
@Override
public void visitTopLevel(JCCompilationUnit tree) {
JavaFileObject prev = log.useSource(tree.sourcefile);
boolean addEnv = false;
......@@ -289,13 +290,13 @@ public class Enter extends JCTree.Visitor {
tree.packge = syms.unnamedPackage;
}
tree.packge.complete(); // Find all classes in package.
Env<AttrContext> env = topLevelEnv(tree);
Env<AttrContext> topEnv = topLevelEnv(tree);
// Save environment of package-info.java file.
if (isPkgInfo) {
Env<AttrContext> env0 = typeEnvs.get(tree.packge);
if (env0 == null) {
typeEnvs.put(tree.packge, env);
typeEnvs.put(tree.packge, topEnv);
} else {
JCCompilationUnit tree0 = env0.toplevel;
if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
......@@ -306,7 +307,7 @@ public class Enter extends JCTree.Visitor {
if (addEnv || (tree0.packageAnnotations.isEmpty() &&
tree.docComments != null &&
tree.docComments.get(tree) != null)) {
typeEnvs.put(tree.packge, env);
typeEnvs.put(tree.packge, topEnv);
}
}
}
......@@ -322,14 +323,15 @@ public class Enter extends JCTree.Visitor {
c.members_field = new Scope(c);
tree.packge.package_info = c;
}
classEnter(tree.defs, env);
classEnter(tree.defs, topEnv);
if (addEnv) {
todo.append(env);
todo.append(topEnv);
}
log.useSource(prev);
result = null;
}
@Override
public void visitClassDef(JCClassDecl tree) {
Symbol owner = env.info.scope.owner;
Scope enclScope = enterScope(env);
......@@ -435,6 +437,7 @@ public class Enter extends JCTree.Visitor {
* Enter a symbol for type parameter in local scope, after checking that it
* is unique.
*/
@Override
public void visitTypeParameter(JCTypeParameter tree) {
TypeVar a = (tree.type != null)
? (TypeVar)tree.type
......@@ -448,6 +451,7 @@ public class Enter extends JCTree.Visitor {
/** Default class enter visitor method: do nothing.
*/
@Override
public void visitTree(JCTree tree) {
result = null;
}
......@@ -489,10 +493,8 @@ public class Enter extends JCTree.Visitor {
for (JCCompilationUnit tree : trees) {
if (tree.starImportScope.elems == null) {
JavaFileObject prev = log.useSource(tree.sourcefile);
Env<AttrContext> env = typeEnvs.get(tree);
if (env == null)
env = topLevelEnv(tree);
memberEnter.memberEnter(tree, env);
Env<AttrContext> topEnv = topLevelEnv(tree);
memberEnter.memberEnter(tree, topEnv);
log.useSource(prev);
}
}
......
......@@ -607,10 +607,12 @@ public class TransTypes extends TreeTranslator {
public void visitNewArray(JCNewArray tree) {
tree.elemtype = translate(tree.elemtype, null);
translate(tree.dims, syms.intType);
tree.elems = translate(tree.elems,
(tree.type == null) ? null
: erasure(types.elemtype(tree.type)));
tree.type = erasure(tree.type);
if (tree.type != null) {
tree.elems = translate(tree.elems, erasure(types.elemtype(tree.type)));
tree.type = erasure(tree.type);
} else {
tree.elems = translate(tree.elems, null);
}
result = tree;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册