bug
bug copied to clipboard
Optimizer preserves tuple for match failure case
Reproduction steps
Scala version: 2.13.12
def t8790(i: Int, j: Int) =
(i, j) match {
case (42, 27) => i+j
//case _ => ???
}
def slow(x: Int, y: Int): String = (x, y) match {
case (7, 8) => "You got it!"
case _ => "No such luck."
}
Problem
Under -opt:local, the tuple is not eliminated if it is used for the match error. However, it is always allocated instead of only in the failure case.
It would be nice to warn -Wopt if a tuple allocation is not eliminated.