diff options
3 files changed, 18 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index c094422533..856cc44e74 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -1104,7 +1104,6 @@ trait ParallelMatching { case Nil => ErrorRule() case Row(pats, subst, g, bx)::xs => - var bnd = subst; var px = 0; var rpats = pats; var bnd = subst; var temps = temp; while(rpats ne Nil){ val (vs,p) = strip(rpats.head); if (!isDefaultPattern(p)) { diff --git a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala index d1208c92a0..191461398f 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala @@ -126,26 +126,24 @@ trait PatternNodes { self: transform.ExplicitOuter => final def getCaseTag(x:Type): Int = { x.typeSymbol.tag } final def definedVars(x:Tree): SymList = { - var vs = new collection.mutable.ListBuffer[Symbol] - def definedVars1(x:Tree): Unit = x match { - case Alternative(bs) => ; // must not have any variables + // I commented out the no-op cases, but left them in case the order is somehow significant -- paulp + def definedVars1(x:Tree): SymList = x match { + // case Alternative(bs) => ; // must not have any variables case Apply(_, args) => definedVars2(args) - case b @ Bind(_,p) => vs += b.symbol; definedVars1(p) - case Ident(_) => ; - case Literal(_) => ; - case Select(_,_) => ; + case b @ Bind(_,p) => b.symbol :: definedVars1(p) + // case Ident(_) => ; + // case Literal(_) => ; + // case Select(_,_) => ; case Typed(p,_) => definedVars1(p) //otherwise x @ (_:T) case UnApply(_,args) => definedVars2(args) - // regexp specific case ArrayValue(_,xs)=> definedVars2(xs) - case Star(p) => ; // must not have variables - } - def definedVars2(args:List[Tree]): Unit = { - var xs = args; while(xs ne Nil) { definedVars1(xs.head); xs = xs.tail }; + // case Star(p) => ; // must not have variables + case _ => Nil } - definedVars1(x); - vs.toList + def definedVars2(args: List[Tree]): SymList = args.flatMap(definedVars1) + + definedVars1(x) } /** pvar: the symbol of the pattern variable diff --git a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala index fe59ce47b6..10cd6cfdd4 100644 --- a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala +++ b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala @@ -57,7 +57,7 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall val vds = new ListBuffer[Tree] var root:Symbol = newVar(selector.pos, selector.tpe) if (!doCheckExhaustive) - root.setFlag(symtab.Flags.TRANS_FLAG) + root.setFlag(Flags.TRANS_FLAG) var vdef:Tree = typed{ValDef(root, selector)} var theFailTree:Tree = ThrowMatchError(selector.pos, mkIdent(root)) @@ -73,7 +73,7 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall for ((ti, i) <- args.zipWithIndex){ val v = newVar(ti.pos, cunit.fresh.newName(ti.pos, "tp"), selector.tpe.typeArgs(i)) if (!doCheckExhaustive) - v.setFlag(symtab.Flags.TRANS_FLAG) + v.setFlag(Flags.TRANS_FLAG) vds += typedValDef(v, ti) tmps += v } @@ -104,11 +104,10 @@ trait TransMatcher { self: transform.ExplicitOuter with PatternNodes with Parall object resetTrav extends Traverser { override def traverse(x: Tree): Unit = x match { - case vd @ ValDef(_, _, _, _) => - if (vd.symbol hasFlag symtab.Flags.SYNTHETIC) { - vd.symbol resetFlag symtab.Flags.TRANS_FLAG - vd.symbol resetFlag symtab.Flags.MUTABLE - } + case (vd: ValDef) => if (vd.symbol hasFlag Flags.SYNTHETIC) { + vd.symbol resetFlag Flags.TRANS_FLAG + vd.symbol resetFlag Flags.MUTABLE + } case _ => super.traverse(x) } |