Skip to content

Commit 8de6223

Browse files
committed
Quick-fix non-idempotent code generated by pattern match
1 parent f85ee4e commit 8de6223

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package transform
33

44
import core._
55
import MegaPhase._
6-
import collection.mutable
6+
import scala.collection.mutable
77
import SymDenotations._, Symbols._, Contexts._, Types._, Names._, StdNames._, NameOps._
88
import ast.Trees._
99
import util.Positions._
@@ -629,7 +629,9 @@ object PatternMatcher {
629629
* Propagate common variable bindings as parameters into case labels.
630630
*/
631631
private def mergeVars(plan: Plan): Plan = {
632+
val RHSs = mutable.LinkedHashSet.empty[RHS]
632633
class RHS(val tree: Tree) {
634+
RHSs += this
633635
override def equals(that: Any) = that match {
634636
case that: RHS => this.tree === that.tree
635637
case _ => false
@@ -700,7 +702,8 @@ object PatternMatcher {
700702
}
701703
val newArgs =
702704
for {
703-
(rhs, actual) <- seenVars.toList
705+
rhs <- RHSs.toList
706+
actual <- seenVars.get(rhs)
704707
formal <- paramsOfLabel(plan.label).get(rhs)
705708
}
706709
yield (formal -> actual)

0 commit comments

Comments
 (0)