Closed ex-ratt closed 3 months ago
The help text indicates that leading infix is available only under -Xsource:3-cross
. This was changed to offer more control over migration (of projects to Scala 3). In Scala 2.13.14, -Xsource-features
will allow more fine-grained opt-in to these features.
➜ scalac -Xsource:help
-Xsource:3 is for migrating a codebase, -Xsource:3-cross is for cross-building.
-Xsource:3 issues migration warnings in category `cat=scala3-migration`,
which by default are promoted to errors under the `-Wconf` configuration.
Examples of promoted warnings:
* Implicit definitions must have an explicit type
* (x: Any) + "" is deprecated
* Args not adapted to unit value
* Member classes cannot shadow a same-named class defined in a parent
* Presence or absence of parentheses in overrides must match exactly
Certain benign syntax features are enabled:
* case C(xs*) =>
* A & B type intersection
* import p.*
* import p.m as n
* import p.{given, *}
* Eta-expansion `x.m` of methods without trailing `_`
The following constructs emit a migration warning under -Xsource:3. With
-Xsource:3-cross the semantics change to match Scala 3 and no warning is issued.
* Unicode escapes in raw interpolations and triple-quoted strings
* Leading infix operators continue the previous line
* Interpolator must be selectable from `scala.StringContext`
* Case class copy and apply have the same access modifier as the constructor
* The inferred type of an override is taken from the member it overrides
There is mention on https://github.com/scala/scala/releases/tag/v2.13.13 but I'm not sure how to add big red letters. This confusion has come up on chat as well.
Normally -X
means "stable option", and -Xsource:N
has specific meaning, although -Xsource:future
has always meant an evolving target. Since Scala 2 has no future versions, the semantics here is a gray area. The breakage is in the service of the migration experience.
The following code compiles and runs with Scala 2.13.12 and
-Xsource:3
compiler flag (we use this flag for nicer syntax, e.g. to allow line breaks before infix operators):With Scala 2.13.13, there are errors on the lines starting with operators. Some of them can be demoted to a warning with
-Wconf:cat=scala3-migration:w
or-Xmigration
, but the boolean operators still won't work:Is there any reason why the boolean operators should not work? I would have assumed that all operators work and not just specific ones, therefore I suspect a bug. But maybe I have missed something?
PS: We have the same problem with
org.http4s.QueryOps.+?
(in another project), so it seems like it isn't confined to boolean operators.PPS:
-Xsource:3-cross
works by the way. With Scala 3.3.3, the above code also works.