use of com.sun.tools.javac.tree.JCTree.JCIndyIdent in project ceylon-compiler by ceylon.
the class Attr method visitIdent.
public void visitIdent(JCIdent tree) {
Symbol sym;
boolean varArgs = false;
// Added by Ceylon
if (tree instanceof JCIndyIdent) {
sym = resolveIndyCall((JCIndyIdent) tree, pt.getParameterTypes());
} else if (pt.tag == METHOD || pt.tag == FORALL) {
// If we are looking for a method, the prototype `pt' will be a
// method type with the type of the call's arguments as parameters.
env.info.varArgs = false;
sym = rs.resolveMethod(tree.pos(), env, tree.name, pt.getParameterTypes(), pt.getTypeArguments());
varArgs = env.info.varArgs;
} else if (tree.sym != null && tree.sym.kind != VAR) {
sym = tree.sym;
} else {
sym = rs.resolveIdent(tree.pos(), env, tree.name, pkind);
}
tree.sym = sym;
// (1) Also find the environment current for the class where
// sym is defined (`symEnv').
// Only for pre-tiger versions (1.4 and earlier):
// (2) Also determine whether we access symbol out of an anonymous
// class in a this or super call. This is illegal for instance
// members since such classes don't carry a this$n link.
// (`noOuterThisPath').
Env<AttrContext> symEnv = env;
boolean noOuterThisPath = false;
if (// we are in an inner class
env.enclClass.sym.owner.kind != PCK && (sym.kind & (VAR | MTH | TYP)) != 0 && sym.owner.kind == TYP && tree.name != names._this && tree.name != names._super) {
// Find environment in which identifier is defined.
while (symEnv.outer != null && !sym.isMemberOf(symEnv.enclClass.sym, types)) {
if ((symEnv.enclClass.sym.flags() & NOOUTERTHIS) != 0)
noOuterThisPath = !allowAnonOuterThis;
symEnv = symEnv.outer;
}
}
// If symbol is a variable, ...
if (sym.kind == VAR) {
VarSymbol v = (VarSymbol) sym;
// ..., evaluate its initializer, if it has one, and check for
// illegal forward reference.
checkInit(tree, env, v, false);
// inner class check that it is final.
if (v.owner.kind == MTH && v.owner != env.info.scope.owner && (v.flags_field & FINAL) == 0) {
log.error(tree.pos(), "local.var.accessed.from.icls.needs.final", v);
}
// that the variable is assignable in the current environment.
if (pkind == VAR)
checkAssignable(tree.pos(), v, null, env);
}
// not accessed before the supertype constructor is called.
if ((symEnv.info.isSelfCall || noOuterThisPath) && (sym.kind & (VAR | MTH)) != 0 && sym.owner.kind == TYP && (sym.flags() & STATIC) == 0) {
chk.earlyRefError(tree.pos(), sym.kind == VAR ? sym : thisSym(tree.pos(), env));
}
Env<AttrContext> env1 = env;
if (sym.kind != ERR && sym.kind != TYP && sym.owner != null && sym.owner != env1.enclClass.sym) {
// enclosing instance:
while (env1.outer != null && !rs.isAccessible(env, env1.enclClass.sym.type, sym)) env1 = env1.outer;
}
result = checkId(tree, env1.enclClass.sym.type, sym, env, pkind, pt, varArgs);
}
Aggregations