case Apply(Tree fn, Tree[] args): if( isSeqApply((Apply) tree ) ) { if ( !delegateSequenceMatching ) { switch (args[0]) { case Sequence(Tree[] ts): return mk.SequencePat( tree.pos, tree.type, ts.length ); } } else { PatternNode res = mk.ConstrPat(tree.pos, tree.type); res.and = mk.Header(tree.pos, header.type, header.selector); res.and.and = mk.SeqContainerPat( tree.pos, tree.type, args[ 0 ] ); return res; } } return mk.ConstrPat(tree.pos, tree.type); case Typed(Ident ident, Tree tpe): PatternNode node = (header.type.isSubType(tpe.type)) ? mk.DefaultPat(tree.pos, tpe.type) : mk.ConstrPat(tree.pos, tpe.type); if ((env != null) && (ident.symbol() != defs.PATTERN_WILDCARD)) switch (node) { case ConstrPat(Symbol casted): env.newBoundVar( ((Tree.Typed)tree).expr.symbol(), tpe.type, gen.Ident(tree.pos, casted)); break; default: env.newBoundVar( ((Tree.Typed)tree).expr.symbol(), tpe.type, header.selector); } return node; case Ident(Name name): if (tree.symbol() == defs.PATTERN_WILDCARD)
case Apply(Tree fn, Tree[] args): if( isSeqApply((Apply) tree ) ) { if ( !delegateSequenceMatching ) { switch (args[0]) { case Sequence(Tree[] ts): return mk.SequencePat( tree.pos, tree.type, ts.length ); } } else { PatternNode res = mk.ConstrPat(tree.pos, tree.type); res.and = mk.Header(tree.pos, header.type, header.selector); res.and.and = mk.SeqContainerPat( tree.pos, tree.type, args[ 0 ] ); return res; } } return mk.ConstrPat(tree.pos, tree.type);  case Typed(Ident ident, Tree tpe): boolean doTest = header.type.isSubType(tpe.type); PatternNode node = doTest ? mk.DefaultPat(tree.pos, tpe.type) : mk.ConstrPat(tree.pos, tpe.type); if ((env != null) && (ident.symbol() != defs.PATTERN_WILDCARD)) switch (node) { case ConstrPat(Symbol casted): env.newBoundVar( ((Tree.Typed)tree).expr.symbol(), tpe.type, gen.Ident(tree.pos, casted)); break; default: env.newBoundVar( ((Tree.Typed)tree).expr.symbol(), tpe.type, doTest ? header.selector : gen.Ident(tree.pos, ((ConstrPat) node).casted)); } return node; case Ident(Name name): if (tree.symbol() == defs.PATTERN_WILDCARD)
    protected PatternNode patternNode(Tree tree, Header header, CaseEnv env) {        switch (tree) {            case Bind(Name name, Tree pat):            	PatternNode node = patternNode(pat, header, env);            	if ((env != null) && (tree.symbol() != defs.PATTERN_WILDCARD))					env.newBoundVar(		tree.symbol(),									tree.type,									header.selector);				return node;			case Apply(Tree fn, Tree[] args):             // pattern with args			    if( isSeqApply((Apply) tree ) ) {				if ( !delegateSequenceMatching ) {				    switch (args[0]) {				    case Sequence(Tree[] ts):					return mk.SequencePat( tree.pos, tree.type, ts.length );				    }				} else { 				    PatternNode res = mk.ConstrPat(tree.pos, tree.type);				    res.and = mk.Header(tree.pos, header.type, header.selector);				    res.and.and = mk.SeqContainerPat( tree.pos, tree.type, args[ 0 ] );				    return res;				}			    }			    return mk.ConstrPat(tree.pos, tree.type);			case Typed(Ident ident, Tree tpe):       // variable pattern				PatternNode node =					(header.type.isSubType(tpe.type)) ?					mk.DefaultPat(tree.pos, tpe.type)					: mk.ConstrPat(tree.pos, tpe.type);				if ((env != null) && (ident.symbol() != defs.PATTERN_WILDCARD))					switch (node) {						case ConstrPat(Symbol casted):							env.newBoundVar(											((Tree.Typed)tree).expr.symbol(),											tpe.type,											gen.Ident(tree.pos, casted));							break;						default:							env.newBoundVar(											((Tree.Typed)tree).expr.symbol(),											tpe.type,											header.selector);					}				return node;			case Ident(Name name):                  // pattern without args or variable				if (tree.symbol() == defs.PATTERN_WILDCARD)					return mk.DefaultPat(tree.pos, header.type);				else if (tree.symbol().isPrimaryConstructor()) {                                    assert false; // this may not happen ??  ----------------- Burak                                    return mk.ConstrPat(tree.pos, tree.type);				} else if (name.isVariable()) {// should be Bind  ------------ Burak                                    assert false;					if (env != null)						env.newBoundVar(										tree.symbol(),										tree.type,										header.selector);					return mk.DefaultPat(tree.pos, header.type);				} else					return mk.VariablePat(tree.pos, tree);			case Select(_, Name name):                                    // variable				if (tree.symbol().isPrimaryConstructor())					return mk.ConstrPat(tree.pos, tree.type);				else					return mk.VariablePat(tree.pos, tree);			case Literal(Object value):				return mk.ConstantPat(tree.pos, tree.type, value);			case Sequence(Tree[] ts):				if ( !delegateSequenceMatching ) {				    return mk.SequencePat(tree.pos, tree.type, ts.length);				} else { 				    return mk.SeqContainerPat(tree.pos, tree.type, tree);				}			case Alternative(Tree[] ts): // CAN THIS WORK ?				assert ts.length > 0;				PatternNode res = patternNode( ts[ 0 ], header, env );				for (int i = 1; i < ts.length; i++) {					res.or = patternNode(ts[i], header, env);					res = res.or ;				}				return res;			default:				new scalac.ast.printer.TextTreePrinter().print(tree).flush();				throw new ApplicationError("unit "+unit+" tree"+tree);        }    }