Symbol owner = realFun.symbol().owner();  if (!classStack.isEmpty() && ((Symbol)classStack.getFirst()).closurePos(owner) != -1) { Symbol thisSym = (Symbol)classStack.getFirst();
int level = outerLevel(realFun.symbol().owner()); if (level >= 0) {
    public Tree transform(Tree tree) {        switch (tree) {        case ClassDef(int mods, _, _, _, _, _) : {            // Add outer link            ClassDef classDef = (ClassDef) tree;            Symbol sym = classDef.symbol();            Tree newTree;            classStack.addFirst(sym);            if (classStack.size() == 1 || Modifiers.Helper.isStatic(mods)) {                outerLinks.addFirst(null);                newTree = super.transform(tree);            } else                newTree = addOuterLink(classDef);            outerLinks.removeFirst();            classStack.removeFirst();            return newTree;        }        case Ident(Name name): {            if (! name.isTermName())                return super.transform(tree);            // Follow "outer" links to fetch data in outer classes.            Symbol sym = tree.symbol();            Symbol owner = sym.classOwner();            Iterator classIt = classStack.iterator();            boolean found = false;            int level = -1;            while (!found && classIt.hasNext()) {                Symbol classSym = (Symbol)classIt.next();                if (classSym.closurePos(owner) != -1)                    found = true;                ++level;            }            if (found && level > 0) {                Tree root = outerRef(level);                return gen.mkStable(gen.Select(root, sym));            } else {                return super.transform(tree);            }        }        case Apply(Tree fun, Tree[] args): {            // Add outer parameter to constructor calls.            Tree realFun;            Tree[] typeArgs;            switch (fun) {            case TypeApply(Tree fun2, Tree[] tArgs):                realFun = fun2; typeArgs = tArgs; break;            default:                realFun = fun; typeArgs = null; break;            }            Tree newFun = null, newArg = null;            if (realFun.hasSymbol() && realFun.symbol().isPrimaryConstructor()) {                switch (transform(realFun)) {                case Select(Tree qualifier, Name selector): {                    if (! (qualifier.hasSymbol()                           && Modifiers.Helper.isNoVal(qualifier.symbol().flags))) {                        newFun = make.Ident(qualifier.pos, selector)                            .setType(realFun.type())                            .setSymbol(realFun.symbol());                        newArg = qualifier;                    }                } break;                case Ident(Name name): {                    Symbol owner = realFun.symbol().owner();                    if (!classStack.isEmpty()                        && ((Symbol)classStack.getFirst()).closurePos(owner) != -1) {                        Symbol thisSym = (Symbol)classStack.getFirst();                        newFun = realFun;                        newArg = gen.This(realFun.pos, thisSym);                    }                } break;                default:                    throw global.fail("unexpected node in constructor call");                }                if (newFun != null && newArg != null) {                    Tree[] newArgs = new Tree[args.length + 1];                    newArgs[0] = newArg;                    System.arraycopy(args, 0, newArgs, 1, args.length);                    Tree finalFun;                    if (typeArgs != null)                        finalFun = copy.TypeApply(fun, newFun, typeArgs);                    else                        finalFun = newFun;                    finalFun.type = addValueParam(finalFun.type,                                                  outerSym(realFun.symbol()));                    return copy.Apply(tree, finalFun, transform(newArgs));                } else                    return super.transform(tree);            } else                return super.transform(tree);        }        default:            return super.transform(tree);        }    }