Tree.EMPTY_ARRAY).setType(ts.type().resultType().asSeenFrom(casted.type(), ts.owner())));
Tree.EMPTY_ARRAY).setType(accType.resultType()));
    public PatternNode enter1(Tree pat,                             int index,                             PatternNode target,                             Symbol casted,                             CaseEnv env) {        //System.out.println("enter(" + pat + ", " + index + ", " + target + ", " + casted + ")");        // get pattern arguments        Tree[] patArgs = patternArgs(pat);        // advance one step in pattern        Header curHeader = (Header)target.and;        // check if we have to add a new header        if (curHeader == null) {            assert index >= 0 : casted;            if (casted.pos == Position.FIRSTPOS) {                Symbol atSym = casted.type().lookup(APPLY_N);                Type seqType = casted.type().baseType(defs.SEQ_CLASS).typeArgs()[0];                Tree t = make.Select(                            pat.pos,                            make.Ident(pat.pos, casted.name)                                .setType(casted.type())                                .setSymbol(casted),                            APPLY_N);                switch (atSym.type()) {                    case OverloadedType(Symbol[] alts, Type[] alttypes):                        infer.methodAlternative(t, alts, alttypes,                            new Type[]{defs.INT_TYPE}, seqType);                        t = make.Apply(pat.pos, t,                                new Tree[]{                                    make.Literal(pat.pos, new Integer(index))                                        .setType(defs.INT_TYPE)                                }).setType(seqType);                        break;                    default:                        t.setSymbol(atSym);                        t.setType(atSym.type());                        t = make.Apply(pat.pos, t,                                new Tree[]{                                    make.Literal(pat.pos, new Integer(index))                                        .setType(defs.INT_TYPE)                                }).setType(seqType);                }                target.and = curHeader = mk.Header(pat.pos, seqType, t);            } else {                Symbol ts = ((ClassSymbol) casted.type().symbol())                    .caseFieldAccessor(index);//                 target.and = curHeader = mk.Header(//                     pat.pos,//                     getHeaderType(typeOf0(ts)),//                     make.Select(//                             pat.pos,//                             make.Ident(pat.pos, casted.name)//                                 .setType(typeOf(casted))//                                 .setSymbol(casted),//                             ts.name)//                             .setType(getHeaderType(typeOf0(ts)))//                             .setSymbol(ts));                target.and = curHeader = mk.Header(                    pat.pos,                    ts.type().resultType(),                    make.Apply(                        pat.pos,                        make.Select(                            pat.pos,                            make.Ident(pat.pos, casted.name)                                .setType(casted.type())                                .setSymbol(casted),                            ts.name)                            .setType(Type.MethodType(                                      Symbol.EMPTY_ARRAY,                                       ts.type().resultType()))                            .setSymbol(ts),                        Tree.EMPTY_ARRAY).setType(ts.type().resultType().asSeenFrom(casted.type(), ts.owner())));            }            curHeader.or = patternNode(pat, curHeader, env);            return enter(patArgs, curHeader.or, casted, env);        }        // find most recent header        while (curHeader.next != null)            curHeader = curHeader.next;         // create node        PatternNode patNode = patternNode(pat, curHeader, env);        PatternNode next = curHeader;        // enter node        while (true)            if (samePat(next, patNode))                return enter(patArgs, next, casted, env);            else if (isDefaultPat(next) ||                     ((next.or == null) &&                     	(isDefaultPat(patNode) || superPat(next, patNode))))                return enter(                    patArgs,                    (curHeader = (curHeader.next =                        mk.Header(patNode.pos, curHeader.type, curHeader.selector))).or                            = patNode,                    casted,                    env);            else if (next.or == null)                return enter(patArgs, next.or = patNode, casted, env);            else                next = next.or;    }