Method from com.sun.tools.javac.comp.Lower$FreeVarCollector Detail: |
public void visitApply(JCMethodInvocation tree) {
if (TreeInfo.name(tree.meth) == names._super) {
addFreeVars((ClassSymbol) TreeInfo.symbol(tree.meth).owner);
Symbol constructor = TreeInfo.symbol(tree.meth);
ClassSymbol c = (ClassSymbol)constructor.owner;
if (c.hasOuterInstance() &&
tree.meth.getTag() != JCTree.SELECT &&
outerThisStack.head != null)
visitSymbol(outerThisStack.head);
}
super.visitApply(tree);
}
If tree refers to a superclass constructor call,
add all free variables of the superclass. |
public void visitIdent(JCIdent tree) {
result = tree;
visitSymbol(tree.sym);
}
If tree refers to a variable in owner of local class, add it to
free variables list. |
public void visitNewClass(JCNewClass tree) {
ClassSymbol c = (ClassSymbol)tree.constructor.owner;
addFreeVars(c);
if (tree.encl == null &&
c.hasOuterInstance() &&
outerThisStack.head != null)
visitSymbol(outerThisStack.head);
super.visitNewClass(tree);
}
If tree refers to a class instance creation expression
add all free variables of the freshly created class. |
public void visitSelect(JCFieldAccess tree) {
if ((tree.name == names._this || tree.name == names._super) &&
tree.selected.type.tsym != clazz &&
outerThisStack.head != null)
visitSymbol(outerThisStack.head);
super.visitSelect(tree);
}
If tree refers to a qualified this or super expression
for anything but the current class, add the outer this
stack as a free variable. |