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
val (x: String) :: _ = xs // error: pattern's type String is more specialized
16
16
// than the right-hand side expression's type Any
17
17
```
18
-
This code gives a compile-time warning in Scala 3.1 (and also in Scala 3.0 under the `-source 3.1` setting) whereas it will fail at runtime with a `ClassCastException` in Scala 2. In Scala 3.1, a pattern binding is only allowed if the pattern is _irrefutable_, that is, if the right-hand side's type conforms to the pattern's type. For instance, the following is OK:
18
+
This code gives a compile-time warning in Scala 3.1 (and also in Scala 3.0 under the `-source future` setting) whereas it will fail at runtime with a `ClassCastException` in Scala 2. In Scala 3.1, a pattern binding is only allowed if the pattern is _irrefutable_, that is, if the right-hand side's type conforms to the pattern's type. For instance, the following is OK:
The new syntax is supported in Scala 3.0. However, to enable smooth cross compilation between Scala 2 and Scala 3, the changed behavior and additional type checks are only enabled under the `-source 3.1` setting. They will be enabled by default in version 3.1 of the language.
59
+
The new syntax is supported in Scala 3.0. However, to enable smooth cross compilation between Scala 2 and Scala 3, the changed behavior and additional type checks are only enabled under the `-source future` setting. They will be enabled by default in version 3.1 of the language.
Copy file name to clipboardExpand all lines: docs/docs/reference/contextual/context-bounds.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ def g[T <: B : C](x: T): R = ...
32
32
To ease migration, context bounds in Dotty map in Scala 3.0 to old-style implicit parameters
33
33
for which arguments can be passed either with a `(using ...)` clause or with a normal application. From Scala 3.1 on, they will map to context parameters instead, as is described above.
34
34
35
-
If the source version is `3.1` and the `-migration` command-line option is set, any pairing of an evidence
35
+
If the source version is `future` and the `-migration` command-line option is set, any pairing of an evidence
36
36
context parameter stemming from a context bound with a normal argument will give a migration
37
37
warning. The warning indicates that a `(using ...)` clause is needed instead. The rewrite can be
@@ -62,7 +62,7 @@ to `Matchable`. If that's not the case a warning is issued. For instance when co
62
62
```
63
63
64
64
To allow migration from Scala 2 and cross-compiling
65
-
between Scala 2 and 3 the warning is turned on only for `-source 3.1-migration` or higher.
65
+
between Scala 2 and 3 the warning is turned on only for `-source future-migration` or higher.
66
66
67
67
`Matchable` is a universal trait with `Any` as its parent class. It is
68
68
extended by both `AnyVal` and `AnyRef`. Since `Matchable` is a supertype of every concrete value or reference class it means that instances of such classes can be matched as before. However, match selectors of the following types will produce a warning:
Copy file name to clipboardExpand all lines: docs/docs/reference/other-new-features/open-classes.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,4 +76,4 @@ A class that is neither `abstract` nor `open` is similar to a `sealed` class: it
76
76
77
77
### Migration
78
78
79
-
`open` is a new modifier in Scala 3. To allow cross compilation between Scala 2.13 and Scala 3.0 without warnings, the feature warning for ad-hoc extensions is produced only under `-source 3.1`. It will be produced by default from Scala 3.1 on.
79
+
`open` is a new modifier in Scala 3. To allow cross compilation between Scala 2.13 and Scala 3.0 without warnings, the feature warning for ad-hoc extensions is produced only under `-source future`. It will be produced by default from Scala 3.1 on.
Copy file name to clipboardExpand all lines: docs/docs/usage/language-versions.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,18 @@ title: "Language Versions"
5
5
6
6
The default Scala language version currently supported by the Dotty compiler is `3.0`. There are also other language versions that can be specified instead:
7
7
8
-
-`3.1`: A preview of changes introduced in the next version after 3.0. Some Scala-2 specific idioms will be dropped in this version. The feature set supported by this version will be refined over time as we approach its release.
9
-
10
8
-`3.0-migration`: Same as `3.0` but with a Scala 2 compatibility mode that helps moving Scala 2.13 sources over to Scala 3. In particular, it
11
9
12
10
- flags some Scala 2 constructs that are disallowed in Scala 3 as migration warnings instead of hard errors,
13
11
- changes some rules to be more lenient and backwards compatible with Scala 2.13
14
12
- gives some additional warnings where the semantics has changed between Scala 2.13 and 3.0
15
13
- in conjunction with `-rewrite`, offer code rewrites from Scala 2.13 to 3.0.
16
14
17
-
-`3.1-migration`: Same as `3.1` but with additional helpers to migrate from `3.0`. Similarly to the helpers available under `3.0-migration`, these include migration warnings and optional rewrites.
15
+
-`future`: A preview of changes introduced in the next versions after 3.0. In the doc pages here we refer to the language version with these changes as `3.1`, but it might be that some of these changes will be rolled out in later `3.x` versions.
16
+
17
+
Some Scala-2 specific idioms will be dropped in this version. The feature set supported by this version will be refined over time as we approach its release.
18
+
19
+
-`future-migration`: Same as `future` but with additional helpers to migrate from `3.0`. Similarly to the helpers available under `3.0-migration`, these include migration warnings and optional rewrites.
18
20
19
21
There are two ways to specify a language version.
20
22
@@ -23,9 +25,10 @@ There are two ways to specify a language version.
23
25
24
26
```scala
25
27
packagep
26
-
importscala.language.`3.1`
28
+
importscala.language.`future-migration`
27
29
28
30
classC { ... }
29
31
```
30
32
31
-
Language imports supersede command-line settings in the compilation units where they are specified. Only one language import is allowed in a compilation unit, and it must come before any definitions in that unit.
33
+
Language imports supersede command-line settings in the compilation units where they are specified. Only one language import specifying a source version is allowed in a compilation unit, and it must come before any definitions in that unit.
0 commit comments