-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Compiler version
scala 3.1.2-RC1-bin-20220118-9e14f5f-NIGHTLY
Minimized code
import scala.annotation.tailrec
class TailrecProblem {
@tailrec
private def create(x: Int): Unit = {
this.synchronized {
if (x == 0) ()
else create(x - 1)
}
}
}
Output
[error] -- Error: TailrecProblem.scala:8:17
[error] 8 | else create(x - 1)
[error] | ^^^^^^^^^^^^^
[error] | Cannot rewrite recursive call: it is not in tail position
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Expectation
It compiles with scala 2.13.7, it does not with 3.1.2-RC1-bin-20220118-9e14f5f-NIGHTLY. Is it a regression or a change in behaviour and synchronized
blocks tailrec invocation?