You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _overviews/scala3-migration/tooling-scala2-xsource3.md
+18-9
Original file line number
Diff line number
Diff line change
@@ -17,22 +17,29 @@ This page explains the details behind the flags. An overview is shown using `sca
17
17
18
18
## Migration vs cross-building
19
19
20
-
With Scala 2.13.13 and newer, the `-Xsource:3` flag comes in two variants:
20
+
With Scala 2.13.14 and newer, the `-Xsource:3` flag comes in three variants:
21
21
22
-
-`Xsource:3` enables warnings relevant for migrating a codebase to Scala 3.
22
+
-`Xsource:3-migration` enables warnings relevant for migrating a codebase to Scala 3.
23
23
In addition to new warnings, the flag enables certain benign Scala 3 syntaxes such as `import p.*`.
24
-
-`Xsource:3-cross` is useful for projects that cross-build between Scala 2 and 3 for a longer period of time.
25
-
For certain language constructs that trigger a warning with `-Xsource:3`, the behavior changes to match Scala 3.
24
+
As a convenience, `Xsource:3` is an alias.
25
+
-`Xsource:3-cross` is useful for projects that cross-build between Scala 2 and 3.
26
+
Certain language constructs have been backported from Scala 3 in order to improve compatibility.
27
+
-`Xsource:3-compat` restricts `3-cross` to binary compatible features. Other binary incompatible
28
+
features can be added using `-Ysource-options`.
26
29
27
30
Details about individual warnings are listed below on this page.
28
31
29
-
## Fatal warnings and quick fixes
32
+
## Warnings as errors, and quick fixes
30
33
31
-
By default, Scala 3 migration warnings emitted by Scala 2.13 are fatal, i.e., they are reported as errors.
32
-
This can be changed using `-Wconf`, for example `-Wconf:cat=scala3-migration:w` changes them to be reported as warnings.
33
-
Alternatively, `-Xmigration` has the same effect.
34
+
By default, Scala 3 migration warnings emitted by Scala 2.13 are reported as errors,
35
+
using the default configuration, `-Wconf:cat=scala3-migration:e`.
36
+
That ensures that migration messaging is more visible.
37
+
Diagnostics can be emitted as warnings by specifying `-Wconf:cat=scala3-migration:w`.
38
+
Typically, emitting warnings instead of errors will cause more diagnostics to be reported,
39
+
so that can be either informative or noisy.
34
40
35
-
The [`@nowarn` annotation](https://www.scala-lang.org/api/current/scala/annotation/nowarn.html) can be used to suppress individual warnings, which also works with fatal warnings enabled.
41
+
The [`@nowarn` annotation](https://www.scala-lang.org/api/current/scala/annotation/nowarn.html) can be used to suppress individual warnings.
42
+
Diagnostics are suppressed before they are promoted to errors, so the annotation works whatever the `-Wconf`.
36
43
37
44
The Scala 2.13 compiler implements quick fixes for many Scala 3 migration warnings.
38
45
Quick fixes are displayed in Metals-based IDEs (not yet in IntelliJ), and they can be applied directly to the source code using the `-quickfix` flag, for example `-quickfix:cat=scala3-migration`.
@@ -83,6 +90,8 @@ It is possible to work around this using version-dependent source files, see [sc
83
90
84
91
Working around the case companion `FunctionN` parent change is currently difficult (Scala 2.13.13), a solution is being discussed at [scala/bug#12961](https://github.com/scala/bug/issues/12961).
85
92
93
+
Binary incompatible features can be used selectively under `-Xsource:3-compat` and `-Ysource-options` where the features can be enumerated.
94
+
86
95
### Changes in language semantics
87
96
88
97
The following table shows cases where `-Xsource:3-cross` adopts language feature semantics from Scala 3.
0 commit comments