Upon compilation of the following
/* sbt = 1.6.2
* scalaVersion := "3.1.1"
* scalacOptions ++= Seq("-explain","-indent","-new-syntax") */
object NewSyntax:
def test1(x: Int, y: Int) = if x == y then "equal" else "different"
def test2(x: Int, y: Int) = if (x == y) then "equal" else "different"
def test3(x: Int, y: Int) = if ((x - y) == 0) then "equal" else "different"
def test4(x: Int, y: Int) = if (x - y) == 0 then "equal" else "different"
the first methods compile fine, but the latter gives:
[error] -- Error: .../scala3/src/main/scala/Main.scala:4:33
[error] 4 | def test4(x: Int, y: Int) = if (x - y) == 0 then "equal" else "different"
[error] | ^^^^^^^
[error] |This construct is not allowed under -new-syntax.
[error] |This construct can be rewritten automatically under -new-syntax -rewrite -source 3.0-migration.
why is that?