if (funSym == ARRAY_CONSTRUCTOR) return super.transform(tree); else { Tree[] newVArgs = transform(vargs); Tree[] finalVArgs = new Tree[newVArgs.length + targs.length]; for (int i = 0; i < targs.length; ++i) finalVArgs[i] = typeAsValue(targs[i].pos, targs[i].type, currentOwner, EENV); System.arraycopy(newVArgs, 0, finalVArgs, targs.length, newVArgs.length); return gen.mkApplyTV(tree.pos, transform(fun), targs, finalVArgs); } }
Tree[] newVArgs = transform(vargs); Tree[] finalVArgs = new Tree[newVArgs.length + targs.length]; for (int i = 0; i < targs.length; ++i) finalVArgs[i] = typeAsValue(targs[i].pos, targs[i].type, currentOwner, EENV); System.arraycopy(newVArgs, 0, finalVArgs, targs.length, newVArgs.length); return gen.mkApplyTV(tree.pos, transform(fun), targs, finalVArgs); } else return super.transform(tree);
        public Tree transform0(Tree tree) {            switch (tree) {            case ClassDef(int mods, //:                          Name name,                          Tree.AbsTypeDef[] tparams,                          Tree.ValDef[][] vparams,                          Tree tpe,                          Tree.Template impl):                Symbol sym = tree.symbol();//                 if (impl.symbol().isNone())//                     throw new Error("no symbol for " + tree);                TreeList newBody =                    new TreeList(transform(impl.body, impl.symbol()));                // Add members (accessors and instantiators)                NewMember[] toAdd = membersToAdd(sym);                for (int i = 0; i < toAdd.length; ++i) {                    switch (toAdd[i]) {                    case TypeAccessor(Symbol memSym, Symbol accSym):                        newBody.append(typeAccessorBody(memSym, accSym));                        break;                    case TypeConstructor(Symbol memSym, Symbol tcSym):                        newBody.append(tConstructorVal(memSym, tcSym));                        break;                    case Instantiator(Symbol memSym, Symbol insSym):                        newBody.append(instantiatorBody(memSym, insSym));                        break;                    case ClassInitialiser(Symbol memSym,                                          Symbol ciSym,                                          Symbol tcSym):                        newBody.append(classInitialiser(memSym, ciSym, tcSym));                        break;                    }                }                Symbol pConst = sym.primaryConstructor();                return gen.ClassDef(sym,                                    transform(impl.parents, pConst),                                    impl.symbol(),                                    newBody.toArray());            case DefDef(_, _, _, _, _, Tree rhs):                Symbol symbol = getSymbolFor(tree);                // TODO maybe use "overrides" method instead of name                // to identify the "getType" method.                if (symbol.name == Names.getType) {                    // Correct the body of the getType method which,                    // until now, was a placeholder (introduced by                    // RefCheck).                    rhs = scalaClassType(symbol.pos,                                         symbol.owner().type(),                                         symbol,                                         EENV);                }                return gen.DefDef(symbol, transform(rhs, symbol));            case ValDef(_, _, Tree tpe, Literal(AConstant.ZERO)):                // transform default values:                //   val x: T = _                // becomes                //   val x: T = asValue(T).defaultValue()                Symbol symbol = getSymbolFor(tree);                Tree defaultValue =                    gen.mkRef(tree.pos,                              typeAsValue(tree.pos,                                          tpe.type,                                          currentOwner,                                          EENV),                              defs.TYPE_DEFAULTVALUE());                Tree rhs = gen.mkApply__(tree.pos, defaultValue);                return gen.ValDef(symbol, rhs);            case ValDef(_, _, _, Tree rhs):                Symbol symbol = getSymbolFor(tree);                return gen.ValDef(symbol, transform(rhs, symbol));            case New(Apply(TypeApply(Tree fun, Tree[] targs), Tree[] vargs)):                if (fun.symbol() == ARRAY_CONSTRUCTOR && false) {                    // Transform array creations:                    //   new Array[T](size)                    // becomes                    //   asValue(T).newArray[T](size)                    assert targs.length == 1;                    assert vargs.length == 1;                    Tree newArrayfun = gen.mkRef(tree.pos,                                                 typeAsValue(targs[0].pos,                                                             targs[0].type,                                                             currentOwner,                                                             EENV),                                                 defs.TYPE_NEWARRAY());                    return gen.mkApplyTV(newArrayfun, targs, vargs);                } else                    return super.transform(tree);            case Apply(TypeApply(Tree fun, Tree[] targs), Tree[] vargs):                Symbol funSym = fun.symbol();                if (funSym == defs.ANY_IS) {                    assert targs.length == 1 && vargs.length == 0;                    Type type = targs[0].type;                    Tree expr = transform(qualifierOf(fun));                    return isTrivialType(type)                        ? super.transform(tree)                        : genInstanceTest(tree.pos, expr, type);                } else if (funSym == defs.ANY_AS) {                    // Transform instance tests:                    //   e.asInstanceOf[T]                    // becomes:                    //   asValue(T).checkCastability(e).asInstanceOf[T]                    // unless T is a "simple" type for which a Java                    // instance test is sufficient, in which case the                    // expression is left as is.                    assert targs.length == 1 && vargs.length == 0;                    Type type = targs[0].type;                    Tree expr = transform(qualifierOf(fun));                    return isTrivialType(type)                        ? super.transform(tree)                        : genTypeCast(tree.pos, expr, type);                } else {                    // Transform applications to pass types as values:                    //   f[T1, ...](v1, ...)                    // becomes                    //   f[T1, ...](asValue(T1), ..., v1, ...)                    if (funSym == ARRAY_CONSTRUCTOR)                        return super.transform(tree);                    else {                        Tree[] newVArgs = transform(vargs);                        Tree[] finalVArgs =                            new Tree[newVArgs.length + targs.length];                        for (int i = 0; i < targs.length; ++i)                            finalVArgs[i] = typeAsValue(targs[i].pos,                                                        targs[i].type,                                                        currentOwner,                                                        EENV);                        System.arraycopy(newVArgs, 0,                                         finalVArgs, targs.length,                                         newVArgs.length);                        return gen.mkApplyTV(tree.pos,                                             transform(fun),                                             targs,                                             finalVArgs);                    }                }            default:                return super.transform(tree);            }        }