@@ -687,12 +687,12 @@ object PatternMatcher {
687687 val refCount = varRefCount(plan)
688688 val LetPlan (topSym, _) = plan
689689
690- def toDrop (sym : Symbol ) =
691- initializer.contains(sym) &&
692- isPatmatGenerated(sym) &&
693- refCount(sym) <= 1 &&
694- sym != topSym &&
695- isPureExpr(initializer(sym))
690+ def toDrop (sym : Symbol ) = initializer.get(sym) match {
691+ case Some (rhs) =>
692+ isPatmatGenerated(sym) && refCount(sym) <= 1 && sym != topSym && isPureExpr(rhs)
693+ case none =>
694+ false
695+ }
696696
697697 object Inliner extends PlanTransform {
698698 override val treeMap = new TreeMap {
@@ -924,10 +924,11 @@ object PatternMatcher {
924924 def translateMatch (tree : Match ): Tree = {
925925 var plan = matchPlan(tree)
926926 patmatch.println(i " Plan for $tree: ${show(plan)}" )
927- for ((title, optimization) <- optimizations) {
928- plan = optimization(plan)
929- patmatch.println(s " After $title: ${show(plan)}" )
930- }
927+ if (! ctx.settings.YnoPatmatOpt .value)
928+ for ((title, optimization) <- optimizations) {
929+ plan = optimization(plan)
930+ patmatch.println(s " After $title: ${show(plan)}" )
931+ }
931932 val result = emit(plan)
932933 checkSwitch(tree, result)
933934 result
0 commit comments