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
The Scala 2.13 compiler issues helpful migration warnings with the `-Xsource:3` flag.
11
+
11
12
Before moving to the Scala 3 compiler, it's recommended to enable this flag in Scala 2 and address the new warnings.
12
-
In addition to new warnings, the flag enables certain benign Scala 3 syntaxes such as `import p.*`.
13
13
14
-
This page explains the details behind the flag, an overview is shown using `scalac -Xsource:help`.
14
+
There is also a variant, `-Xsource:3-cross`; see below.
15
+
16
+
This page explains the details behind the flags. An overview is shown using `scalac -Xsource:help`.
15
17
16
18
## Migration vs cross-building
17
19
18
20
With Scala 2.13.13 and newer, the `-Xsource:3` flag comes in two variants:
19
21
20
22
-`Xsource:3` enables warnings relevant for migrating a codebase to Scala 3.
23
+
In addition to new warnings, the flag enables certain benign Scala 3 syntaxes such as `import p.*`.
21
24
-`Xsource:3-cross` is useful for projects that cross-build between Scala 2 and 3 for a longer period of time.
22
25
For certain language constructs that trigger a warning with `-Xsource:3`, the behavior changes to match Scala 3.
23
26
@@ -37,7 +40,7 @@ See also `scalac -quickfix:help`.
37
40
38
41
## Enabled Scala 3 syntax
39
42
40
-
The `-Xsource:3` flag enables the following Scala 3 syntax in Scala 2:
43
+
The `-Xsource:3` flag enables the following Scala 3 syntaxes in Scala 2:
41
44
42
45
-`import p.*`
43
46
-`import p.m as n`
@@ -46,7 +49,6 @@ The `-Xsource:3` flag enables the following Scala 3 syntax in Scala 2:
46
49
-`A & B` type intersection as an alias for `A with B`
47
50
- Selecting a method `x.f` performs an eta-expansion (`x.f _`), even without an expected type
48
51
49
-
50
52
## Scala 3 migration warnings in detail
51
53
52
54
Many Scala 3 migration warnings are easy to understand and identical under `-Xsource:3` and `-Xsource:3-cross`, e.g., for implicit definitions without an explicit type:
0 commit comments