--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Tue Mar 15 13:48:30 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Thu Mar 17 19:04:28 2016 +0000
@@ -36,6 +36,7 @@
import com.sun.source.tree.TreeVisitor;
import com.sun.source.util.SimpleTreeVisitor;
import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Directive.RequiresFlag;
import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.code.Symbol.*;
@@ -60,6 +61,7 @@
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.JCDiagnostic.Fragment;
import com.sun.tools.javac.util.List;
+
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Flags.ANNOTATION;
import static com.sun.tools.javac.code.Flags.BLOCK;
@@ -332,7 +334,15 @@
syms.errSymbol.name,
null, null, null, null);
localEnv.enclClass.sym = syms.errSymbol;
- return tree.accept(identAttributer, localEnv);
+ return attribIdent(tree, localEnv);
+ }
+
+ /** Attribute a parsed identifier.
+ * @param tree Parsed identifier name
+ * @param env The env to use
+ */
+ public Symbol attribIdent(JCTree tree, Env<AttrContext> env) {
+ return tree.accept(identAttributer, env);
}
// where
private TreeVisitor<Symbol,Env<AttrContext>> identAttributer = new IdentAttributer();
@@ -4238,13 +4248,19 @@
}
/**
- * Attribute an env for either a top level tree or class declaration.
+ * Attribute an env for either a top level tree or class or module declaration.
*/
public void attrib(Env<AttrContext> env) {
- if (env.tree.hasTag(TOPLEVEL))
- attribTopLevel(env);
- else
- attribClass(env.tree.pos(), env.enclClass.sym);
+ switch (env.tree.getTag()) {
+ case MODULEDEF:
+ attribModule(env.tree.pos(), ((JCModuleDecl)env.tree).sym);
+ break;
+ case TOPLEVEL:
+ attribTopLevel(env);
+ break;
+ default:
+ attribClass(env.tree.pos(), env.enclClass.sym);
+ }
}
/**
@@ -4260,6 +4276,21 @@
}
}
+ public void attribModule(DiagnosticPosition pos, ModuleSymbol m) {
+ try {
+ annotate.flush();
+ attribModule(m);
+ } catch (CompletionFailure ex) {
+ chk.completionError(pos, ex);
+ }
+ }
+
+ void attribModule(ModuleSymbol m) {
+ // Get environment current at the point of module definition.
+ Env<AttrContext> env = enter.typeEnvs.get(m);
+ attribStat(env.tree, env);
+ }
+
/** Main method: attribute class definition associated with given class symbol.
* reporting completion failures at the given position.
* @param pos The source position at which completion errors are to be
@@ -4358,6 +4389,10 @@
// nothing to do
}
+ public void visitModuleDef(JCModuleDecl tree) {
+ tree.sym.completeUsesProvides();
+ }
+
/** Finish the attribution of a class. */
private void attribClassBody(Env<AttrContext> env, ClassSymbol c) {
JCClassDecl tree = (JCClassDecl)env.tree;
@@ -4929,4 +4964,22 @@
}
}
// </editor-fold>
+
+ public void setPackageSymbols(JCExpression pid, Symbol pkg) {
+ new TreeScanner() {
+ Symbol packge = pkg;
+ @Override
+ public void visitIdent(JCIdent that) {
+ that.sym = packge;
+ }
+
+ @Override
+ public void visitSelect(JCFieldAccess that) {
+ that.sym = packge;
+ packge = packge.owner;
+ super.visitSelect(that);
+ }
+ }.scan(pid);
+ }
+
}