-
Notifications
You must be signed in to change notification settings - Fork 22
Inliner incorrectly modifies IINC on parameters #13156
Copy link
Copy link
Open
Description
scala/scala@bfa1380#diff-6402881c68d306988091172b129869daad7519257b48d97d2632465789d7383a added handling for VarInsnNode at (new) line 744 of Inliner.scala but missed changing the IincInsnNode case just below.
Thus, IINC instructions aren't properly modified when their target is a parameter.
This was found while porting the optimizer to Scala 3, in which the following is a repro:
//> using options -opt-inline:**
object Test {
def foo(b: Option[Int]): Unit =
fooRec(x = 0, b)
private def fooRec(x: Int, b: Option[Int]): Unit = {
if (b.nonEmpty) {
fooRec(x + 1, b)
}
}
def main(args: Array[String]): Unit = {
foo(None)
}
}
I haven't actually tested it with scala2 but the underlying problem should also exist.
Reactions are currently unavailable